Jump to content

Recommended Posts

Posted (edited)

I would like to export a complex Jasper report containing multiple columns, which need to auto-fit to column widths, to Microsoft Excel (.XLSX) format.

Everything works fine when exporting to .XLS format. However, when I try exporting to .XLSX, the parameters:

<property name="net.sf.jasperreports.export.xls.auto.fit.row" value="true"/>
<property name="net.sf.jasperreports.export.xls.auto.fit.column" value="true"/>

seem to be completely ignored - they should stretch the columns width according to the text content inside them - but in .XLSX this obviously does not work.

The column widths are not adjusted according to the text content. Instead, they remain unchanged.

I have tested this issue across multiple JasperSoft Studio versions, but the problem persists in all of them.

Attached are the "problematic" sections of the .jrxml file and the generated outputs in both .XLS (which displays the correct behavior) and .XLSX (where the parameters appear to be ignored, resulting in a distorted output). The data in the attachments has been anonymized for privacy.

image.thumb.png.156b29b2f7f61de12d22d0cd27c8e223.png

I would like to know:

  1. If this is a known issue or bug.
  2. When a fix might be available.
  3. If there are any "workaround" solutions to resolve the issue.

Thank you in advance for your assistance.

JRXML.xml XLSX - wrong.xlsx XLS - correct.xls

Edited by Marek D.
  • Marek D. changed the title to Issues with auto.fit.row and auto.fit.columns parametrs in export to .xlsx (Excel)
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted (edited)

I respectfully disagree.

Jasper CAN automatically adjust column widths—I have tested this functionality extensively over the years, and it works flawlessly.

However, as mentioned earlier, this feature is only supported when exporting to the .XLS (Excel) format and not .XLSX. Secondly, of course not to other formats, such as PDF, Word - for them such a parametr does not exist of course.

The Jasper engine itself does not perform the adjustment. It simply instructs Microsoft Excel to activate a flag that enables this functionality (you can see that in the attachment).

You can refer to the official documentation for confirmation or test on your own.

https://jasperreports.sourceforge.net/config.reference.html#net.sf.jasperreports.export.xls.auto.fit.column

Additionally, a similar issue has been earlier discussed on this forum (but unfortunatelly was not resolved). Please see the link for more details.

Thank you.

 

 

 

image.png

Edited by Marek D.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...