I have a requirement where I don't know how many columns my report is going to display until runtime. For example lets say if i want to display a report with 10 columns, first i should print the data with 4 columns followed by next 4 columns and the next 2 columns data. Is it possible? Please give me some ideas..... Thanks
I've discovered that just about anything is possible in JasperReports. The problem here is that I don't think you can do this without interfacing with the JasperDesign object at runtime. That is, create your report with 1 column, and then at runtime load the design object and programatically change the columns.
If the API doesn't support it, you could always change the API to support it. (Jasper is OpenSource....)
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Joined: Jul 01, 2004
Do u think i can follow these steps ??? 1. create .jrxml file programatically and dynamically. 2. compile it during runtime. 3. load data. 4. generate report.
You can use IReport to create a template configuration file where you can set the font and other cosmetic things. Once you have finalised the looks then you can read the template xml configuration file at runtime and use JDOM to insert new columns or delete init columns. It involves very basic XML parsing and then rewriting the XML file back to the disk with new 'field' and other corresponding elements . Then jasperreport can pick the xml file from there.
One option could be to give jasperreport a runtime document object, but I havent tried it. Let us know if you can work around with it this way.
also refer to the dtd and before working on configuration file. Note that the XML file requires the elements to be in the same order as in the DTD. Some times when you insert new elements under the root they are inserted at the end of the document
Hope it helps
subject: Is dynamic columns possible in Jasperreport