Jump to content

Array of Array, can this be done ?


JimmyP

Recommended Posts

Hi,

thank you in advance for your time. I have to create an excel report that has a one to many relationship. For example if I have an array of beans and each bean represents the data for one row then jasper reports knows to iterate through the array and map each field in the report to each field in the bean. My problem is I have an Array of Arrays. Where each row is represented by one bean plus if one of the beans fields is an Array(String[]) how can get jasper to print those values out ?

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

If you want all String values printed in the same text field, you could write a Java method (or use org.apache.commons.lang.StringUtils) to concatenate the values into a single String value.

 

Otherwise, you would need to use a subreport for the second level arrays. For this, you would also need to somehow wrap the String array into a JasperReports data source (you can either write a simple data source implementation or convert the String array into a bean/map array/collection so that you would leverage existing data source implementations).

 

Regards,

Lucian

Link to comment
Share on other sites

Thank you Lucianc for your reply. After some thought I decide to just change the data structure and make it all one to one (an array of one String only, no sub arrays, completely flat). The result sets that I'm working with can be quite large (1000 records and each sub record containing as man as 10 records, 1000x10= Large). So creating a datasource for each sub array I thought would be very expensive. Thank you again for your help, maybe in a future release someone will consider implementing type of structure.

 

Jimmy

Link to comment
Share on other sites

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...