Problem with iReport (JasperReports)

I get an extra blank line between the data when I import it from the database and formatting the report in an Excel worksheet.

EDIT (explanation from comment): Excel output shows an extra blank row between records and an extra blank column between fields.

+4
source share
2 answers
  • Add net.sf.jasperreports.export.xls.remove.empty.space.between.columns and net.sf.jasperreports.export.xls.remove.empty.space.between.rows properties for the report.

net.sf.jasperreports.export.xls.remove.empty.space.between.columns . Specifies whether to remove empty separator columns.

net.sf.jasperreports.export.xls.remove.empty.space.between.rows . Indicates whether blank separator lines should be removed.

Sample:

 <jasperReport ...> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <property name="net.sf.jasperreports.export.xls.remove.empty.space.between.columns" value="true"/> <property name="net.sf.jasperreports.export.xls.remove.empty.space.between.rows" value="true"/> 

Information on configuration properties is here .

  • You can set isRemoveLineWhenBlank and isBlankWhenNull for the textField element to hide the empty line.

Example of deleting the entire line if the current text field is empty:

 <textField isBlankWhenNull="true"> <reportElement x="0" y="0" width="100" height="20" isRemoveLineWhenBlank="true"/> <textElement/> <textFieldExpression><![CDATA[$F{field}]]></textFieldExpression> </textField> 
  • Another suggestion is to change the height of all textField elements (or / and staticText) in the group.

In case this design:

design with a space between textField and the band's boundary

you will have a space between any two lines.

In case this design (the height of the text field is equal to the height of the strip): the textfield height is equal to the band's height

each row will be exactly below the other.

+7
source

Every thing that Alex K says in his answer on December 2 is true. But some other settings may be useful. These settings help when the text of the report stretches the range of parts.

On each field in the details set:

positionType = "Float"

stretchType = "RelativeToTallestObject"

Example:

 <detail> <band height="20" splitType="Prevent"> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement positionType="Float" stretchType="RelativeToTallestObject" mode="Transparent" x="372" y="0" width="100" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{your column name}]]></textFieldExpression> </textField> 

This will make all fields be the same height. The float parameter indicates that the field minimizes the distance between the previous and next lines. The RelativeToTallestObject parameter specifies all fields in a strip of the same height as the highest field. These two options help eliminate the β€œblank space” that appears as unwanted cells in Excel.

+3
source

Source: https://habr.com/ru/post/1384285/


All Articles