Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » HowTo read a textfile wwith javascript
HowTo read a textfile wwith javascript [message #360884] Wed, 27 February 2008 09:55 Go to next message
Eclipse UserFriend
Originally posted by: dunkelpeter.spam.gmx.net

Hello!

I want to read the content of a file into a dynamic text.
Birt is running as a application, the file is in the local computer.

An image can be insert with the "file:///c:/test/test.jpg" as URI. I put a
function, that returs the URI in the Expression Builder.

The same thing with the dymanic text (put the URI in the Expression
Builder), I get the filename instead of the file content (I think, this is
okay), but when I try to open the file and read it with JavaScript, I get
an empty string.

Peter
Re: HowTo read a textfile wwith javascript [message #360933 is a reply to message #360884] Thu, 28 February 2008 16:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

Peter,

On a dynamic text onCreate event you can do something like:
importPackage(Packages.java.io);
fr = new FileReader( "c:/xfer/mydt.txt" );
inf = new BufferedReader( fr );
mydata = inf.readLine();
fr.close();
inf.close();
this.text = mydata;

Jason

Peter Dunkel wrote:
> Hello!
>
> I want to read the content of a file into a dynamic text.
> Birt is running as a application, the file is in the local computer.
>
> An image can be insert with the "file:///c:/test/test.jpg" as URI. I put a
> function, that returs the URI in the Expression Builder.
>
> The same thing with the dymanic text (put the URI in the Expression
> Builder), I get the filename instead of the file content (I think, this is
> okay), but when I try to open the file and read it with JavaScript, I get
> an empty string.
>
> Peter
Re: HowTo read a textfile wwith javascript [message #1817034 is a reply to message #360933] Thu, 14 November 2019 11:12 Go to previous messageGo to next message
Emanuele Spatola is currently offline Emanuele SpatolaFriend
Messages: 11
Registered: September 2019
Location: Italy
Junior Member
EDIT: watch the next comment below :)

[Updated on: Thu, 14 November 2019 17:29]

Report message to a moderator

Re: HowTo read a textfile wwith javascript [message #1817052 is a reply to message #360933] Thu, 14 November 2019 17:28 Go to previous message
Emanuele Spatola is currently offline Emanuele SpatolaFriend
Messages: 11
Registered: September 2019
Location: Italy
Junior Member
This solution works with a absolute path.
I tried to write only the name of the txt file and it doesn't work.
How can I solve to this using a relative path??

Thanks
Previous Topic:vertical alignment
Next Topic:Generate xlsx report using birt template and .csv file.
Goto Forum:
  


Current Time: Sat Apr 20 03:24:47 GMT 2024

Powered by FUDForum. Page generated in 0.02821 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top