benz
benz

Reputation: 4629

What is the ideal approach to export reports to Excel and CSV using JasperReports?

I am using iReport designer to export reports into PDF format and CSV formats. Now for the PDF format, everything seems perfect, but when I use the same design to export to CSV, the whole layout goes haywire. I would document all the necessary research i have gathered. Let's have a look at the report format in PDF and then CSV.

PDF Format

PDF Format for the Report

CSV Format

CSV Format for Report

Here is the research gathered.

  1. PDF format is pixel perfect reports where CSV reports.
  2. We can use CSVMetaDataExporter in order to just extract the data and set the column names describing the types and data using export parameters. Though i have not used the second option still.

So my basic question is, if we want to use the same template to export CSV or Excel, we would be obviously running into alignment and width issues. I exported the report to Excel as well and in the Excel format the results were not at all satisfactory. So in this context, is JasperReports really a correct choice to opt for Excel and CSV formats? If it is, what is the ideal approach to deal with such output formats?

Upvotes: 4

Views: 4195

Answers (1)

Israel Lopez
Israel Lopez

Reputation: 1145

In my professional opinion, no. Don't even bother trying to keep the same template format when your output will change from Visual: PDF/On-Screen/Print and Structured: CSV/Excel etc,.

Alex K mentioned the Advanced Excel Features, and when used well it can generate output on screen that will match Excel. However, your design of the elements must be very tight, meaning avoid spanning cells, absolutely positioned elements, snap to grid or snap to other elements.

If your client/user requires the report to look good and be useable in Excel, then you may very well have to design for an Excel format.

Upvotes: 4

Related Questions