Stretch overflow not working in excel jasper report

Pavel picture Pavel · Dec 21, 2014 · Viewed 7k times · Source

I am trying to export report to Excel (XLSX format) using jasper report, but get problems with stretching when text field is overflow. I get just empty cells when value of textfield is bigger than textfield size. I tried to use these parameters, but it isn't helping me:

<property name="net.sf.jasperreports.export.xls.collapse.row.span" value="true"/>
<property name="net.sf.jasperreports.print.keep.full.text" value="true"/>
<property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
<property name="net.sf.jasperreports.export.xls.wrap.text" value="true"/>
<property name="net.sf.jasperreports.export.xls.auto.fit.row" value="true"/>
<property name="net.sf.jasperreports.export.xls.auto.fit.column" value="true"/>

Here is refer to screenshot: http://clip2net.com/s/39cbljj

In HTML it looks ok:

http://c2n.me/39cyhRf

Does anybody know how to fix this? Thanks.

Answer

mike picture mike · Dec 24, 2014

you should do the following to get it working:

  1. Set isStretchWithOverflow="true" for all TextField elements on Detail band (it will fix cutting of long text values)
  2. Set stretchType="RelativeToBandHeight" for all TextField elements on Detail band (It will fix the issue with empty cells - all TextFields will be rendered with the same height)
  3. set the property <property name="net.sf.jasperreports.export.xls.auto.fit.row" value="true"/> on each TextField which may have long value. The point is that property net.sf.jasperreports.export.xls.auto.fit.row works on Element level only.Also please note that this property won't work for merged cells.