Jaspererports iReport: split report into several excel sheets on export - jasper-reports

I have a report which I created using iReport designer. The report contains 3 datasets and 3 tables, which get filled with data from those datasets. Each table is located in detail band. Our business owner wants these 3 tables to be displayed on 3 different excel sheets upon excel export. I have checked several tutorials and posts, but none of them seems to work for me. Help needed! Thanks in advance!

add pagebreak after each table, then set property
net.sf.jasperreports.export.xls.one.page.per.sheet to true
like this
<property name="net.sf.jasperreports.export.xls.one.page.per.sheet" value="true"/>
for more reference visit this page

Related

How may I create a table autofilter on a Jasper .xlsx report output - one autofilter per sheet?

I am creating a Jasper report via Jaspersoft Studio 6
I am using the following property to export my report into two separate Excel sheets (tabs): net.sf.jasperreports.export.xls.break.after.row
My report consists of two tables, one table per sheet. So far, I have no issue creating this report.
However, I would also like to implement an excel auto filter on each table header using the following property: net.sf.jasperreports.export.xls.auto.filter
I added the auto filter property to both table headers, with a start and end on both. But when I run the report, the filter only displays on my last table (the one on the second sheet). I imagine this may happen because in Excel, you are only allowed one autofilter per sheet.
How may I put an autofilter on BOTH tables of a jaspersoft .xlsx report output?

Jasper report - getting duplicate records

We are exploring Jasper reports to replace our current reporting engine. Our data source will be REST APIs, and we'll be needing to join multiple tables. I came across the CData JDBC driver for REST, and it seemed apt for the purpose.
I have created a JDBC data adapter using the CData driver, with a JSON file as a source which has data for 2 entities - users and posts.
Then I created a report with this data adapter to display fields in a table. The data is a result of join query on both the entities as below -
SELECT users.name,users.username,users.email,users.website,posts.title FROM users join posts on users._id = posts.userId
Below is the data adapter configurations -
CDataDataAdapter.xml
<jdbcDataAdapter class="net.sf.jasperreports.data.jdbc.JdbcDataAdapterImpl">
<name>CDataDataAdapter</name>
<driver>cdata.jdbc.rest.RESTDriver</driver>
<username />
<password />
<savePassword>true</savePassword>
<url>jdbc:rest:Format="JSON";URI="D:/Documents/ToJasper/SampleJoinJson.json";XPath="/posts;/users";DataModel="Relational";JSONFormat="JSON";SSLServerCert="*";Logfile="D:\Documents\Tasks\ToJasper\cdata-driver.log";Verbosity="4";Location="D:\Documents\Tasks\ToJasper\Schema";FlattenObjects="False";GenerateSchemaFiles="OnStart";RowScanDepth="10";</url>
<database />
<serverAddress />
<classpath>I:\Program Files\CData\lib\cdata.jdbc.rest.jar</classpath>
<classpath>I:\Program Files\CData\lib\rssbus.jar</classpath>
</jdbcDataAdapter>
The data is fetched the rendered in the report, but the problem is it gets repeated.
The table is repeated in the report 5 times, 4 times with full data, and one time with only column headers. I cannot understand why, any help is greatly appreciated.
I got the answer here - https://community.jaspersoft.com/questions/904196/same-detail-shown-multiple-times-page-and-multiple-pagesireports-well-jaspersoft
I added the table component in the Detail band instead of Summary band. Quoting from the answer above -
"Where did you put the table and chart element in the report? They should be placed in SUMMARY section, not detail section. JR report detail band is called for each row fetched into report. If you have 100 rows, it will display information in the detail band 100 times each with details of that row. Tables and charts gather and tally all your data to display and should be placed in the summary band thus have them displayed only once."

Report vertical layout

I have existing report w/ "groups" for Total/Directs/Warehouse/Credits that span horizontally. I need to now stack these groupings vertically. What is the best way to do this in CR? I am used to SSRS, Excel, PowerBI, etc. Crystal Reports is much less intuitive than those tools.
Do I need some kind of funky nested groups? Sub reports? How should we approach this? We assumed it would be a pretty simple formatting/layout change. But it looks like it's actually quite complex to do this.
Original:
How it needs to be re-worked:
If the entire table you're showing is in a Footer, you can just add 3 new footer sections and duplicate the table in each (removing any columns you don't need.) Just right click the relevant section and Insert Section Below.
Otherwise you'll need to use subreports. But since you have the columns already configured, all you really have to do is:
Save 4 subreports, Total, Directs, Warehouse, and Credits. (Just save a copy of your existing report, and delete everything that doesn't need to show up in Total. Rinse and repeat.)
Import each and add the parameters as subreport links
Give them each their own section

Editing the column size inside subreport using jasper API

I have a jrxml file containing six subreports.
I need to programatically hide the columns displayed in these subreports.
I did search for a solution, but could not find a example for modifying the columns in subreports and I am unable to find a way with jasper API to pick the subreport from JasperReport class.
I did check dynamicreports API. But it seems subreport can't already have columns defined in it.

How to create Excel document with proper cell alignment using Ireport?

I can able to create Excel document using Jasper Report but the problem is that fields are not properly aligned in the cells of excel sheet and all the data are populated in the plain surface without any cells.i.e) I cannot see any cells in the data populated area.Can u please give me suggestion to make proper Excel document with cell alignment.
I had this same struggle and came up with the following. At the time, I was using iReport (3.0.0) and was able to generate a good xls file. It may be easier in newer versions of iReport and/or JasperReports. Here's what I did:
I created a new report using the new report wizard and chose a tabular template. This creates a report with all of the fields in a line with no gaps between them. It is very key that fields are vertically aligned, that all the same height, and that there are no gaps between fields.
I removed all of the extra objects created (title, extra lines) except for the fields and the headers. I then collapsed all of the bands except the column header and detail bands.
On the report properties, I checked "Ignore pagination"
I changed the text color of the header fields, otherwise it ends up as white on white.
The rest of the important options can be found by selecting Options -> Export Options from the menu and then scrolling down to the "XLS Exporter" section. I attached a screen shot of the options I chose. You can experiment with the settings, but I found (through trial and error) that the options I ended up with work pretty well. These options are not stored in the report def file, they are attributes of the thing generating the report. iReport takes care of it when testing in that environment. We are using custom Java to generate the report in production and we set the attributes there.
XLS Exporter Dialog http://www.imagechicken.com/uploads/1270760205041768200.png