Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
adding text to label from a file in filesystem
amrutha
Hello friends,
I have to design a report where i need to fill plain text in label from my loacl file system .my file is located in C:\test.txt...Pls can someone suggest me hw can i do it pls ...i ve tried with REsource key bt we need to change the value for it time and again..So plssss help me
thank you...
Find more posts tagged with
Comments
johnw
You can access any Java library in the scripting and expression environment. As long as you precede any Java package with the Packages string, or use the importPackage method, you would write it as you would any Java routine.
So, you could drop a data element in, and do something like:
var input = new Packages.java.io.BufferedReader(new Packages.java.io.FileReader("text.txt"));
var line = "";
var stringBuilder = new Packages.java.lang.StringBuilder();
while (( line = input.readLine()) != null){
stringBuilder.append(line);
}
input.close();
stringBuilder.toString();
That might take some minor tweaking due to Javascript differences, but thats the basic idea.
John
amrutha
<blockquote class='ipsBlockquote' data-author="'johnw'" data-cid="70761" data-time="1290672103" data-date="25 November 2010 - 01:01 AM"><p>
You can access any Java library in the scripting and expression environment. As long as you precede any Java package with the Packages string, or use the importPackage method, you would write it as you would any Java routine.<br />
<br />
So, you could drop a data element in, and do something like:<br />
<br />
var input = new Packages.java.io.BufferedReader(new Packages.java.io.FileReader("text.txt"));<br />
var line = "";<br />
var stringBuilder = new Packages.java.lang.StringBuilder();<br />
<br />
while (( line = input.readLine()) != null){<br />
stringBuilder.append(line);<br />
}<br />
<br />
input.close();<br />
stringBuilder.toString();<br />
<br />
That might take some minor tweaking due to Javascript differences, but thats the basic idea.<br />
<br />
John<br /></p></blockquote>
amrutha
i don need programmatically i am designing my report manually with help of palette...
johnw
And how does that prevent you from using a Data report item from the palette, and using the above as the expression? The method described uses regular report items from the palette, its not building anything programatically.
kosta
Hi amrutha,
in the Report Designer there is the "Script"-tab between the "Master Page" and the "XML Source" Tabs. There you can use java like scripts for better customizing. Each items has its own script part even the master pages and the data source and data set have it.
In the script view you can see the methods/events/functions in the drop down menu where you can put your script code.