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

13,201

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:

  1. 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.
  2. 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.
  3. On the report properties, I checked "Ignore pagination"
  4. I changed the text color of the header fields, otherwise it ends up as white on white.
  5. 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

Share:
13,201
Kumar
Author by

Kumar

Updated on June 04, 2022

Comments

  • Kumar
    Kumar almost 2 years

    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.