Excel export

Hello Community,


i have the following report with a main and a subreport.


Is there a simple way to export this document (which is layouted for a PDF) directly to excel? Or is only the possibility to change the complete layout?

Thanks for a short feedback and helpful answers.


h.c.b.'s picture
Joined: Apr 22 2015 - 10:22pm
Last seen: 6 months 2 weeks ago

1 Answer:

You have two options:

1) rework your layout to support both pdf and excel by remove all white space in bands, deleting unused bands, ignoring graphics, and adding configuration parameters for excel output such as those found here:


For example: see net.sf.jasperreports.export.xls.detect.cell.type

2) create a separate report template optimized for each output type

I typically go with option two; PDF output deals with a fixed page width/height and printer friendly concerns, excel really doesn't. That alone can require significant differences in layouts. And if your requirements evolve, say now you need to create multiple worksheets in excel but need images etc for pdf, you may be forced at that point to create multiple templates. But like I mentioned, it comes with overhead. If I make a change in logic or computation and need consistent results across output formats, that change needs to be made in multiple places. 

Option one may or may not be simple, export your current report to excel as is and review the results. you may notice many extra columns and rows in excel and eliminating those can be tedious. In my experience it can be done but can be a pain. Also you have to filter out images, fonts, etc., enable cell type detection, check to see if things still work as expected in pdf output, so on and so on.

darth_fader's picture
Joined: Mar 7 2010 - 9:45pm
Last seen: 3 months 3 weeks ago