Jump to content
Changes to the Jaspersoft community edition download ×

Subreport with a plaintext file as datasource


ktrinad

Recommended Posts

By: Sofiane - sofianito

Subreport with a plaintext file as datasource

2004-03-02 08:56

Hi,

I need to fill a subreport with data that come from a plain text file. The values come separated by a (;). I understood that I have to implement JRDataSource to read data from the file, but my problem is that rows that are in the file are not uniform, and beside of this the master report uses also the same datasource.

 

Each line in the file is identified by an id, example:

 

000;value000_1;value000_2;value000_3

002;value002_1

 

100;value100_1;value100_2

200;value200_11;value200_12;value200_13

200;value200_21;value200_22;value200_3

200;value200_31;value200_32;value200_33

300;value300_1

400;value400_1;value400_2

 

in my case, the rows identified by 000 and 002 would appear in the detail of the master report.

In the case of my subreport, the row identified by 100 would go in a group header, 200 would go in the detail of the subreport, 300 in the group footer, and finally 400 in the summary.

 

Well, hoping that my example was understood, it looks like my DataSource is composed of various Sub Datasources. I'm thinking to prefix my report's field names by the id of the correspondant row ( example: <textFieldExpression class="java.lang.String">$F{100_myfield}</textFieldExpression> ), this allows me to bind the field name with the correspondant subdatasource.

 

Is it feasable what am saying? or is there any simplier solution?

 

Thanks in advance

 

 

 

By: David Lim - aberrant80

RE: Subreport with a plaintext file as dataso

2004-03-02 18:35

I think you should use text rather than numbers in your example. I'm confused. Your file appears quite random... could you not derive from JRDataSource and implement some custom file reading code?

 

 

By: Sofiane - sofianito

RE: Subreport with a plaintext file as dataso

2004-03-03 03:21

Hi,

Each field value is separated by a ( ; ). Each line, depending on the first field, has a certain number of columns. If u think database, the file is a set of tables, and each table has a number of columns. I'm trying to extend the JRBeanCollectionDataSource but it doesn't seem trivial. It looks like i need to add subreports to my subreport if u know what i mean. In my subreport I need to add the lines between rowid = 100 and row id = 400.

 

Hope i was clear in my explanation...

 

thanks

 

 

By: David Lim - aberrant80

RE: Subreport with a plaintext file as dataso

2004-03-03 18:51

wow, sounds like a database in one single file... i don't think i can help. all I can think of is that you'd probably have to create multiple classes to represent the different parts of the file. it's either that, or you try to separate that database file.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...