Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
877 views
in Technique[技术] by (71.8m points)

excel - iReport (JasperReports) extra row issue

I am getting an extra empty row between data when I am importing it from the database and formatting the report in Excel sheet.

EDIT (clarification from a comment): The output in Excel shows an extra blank row between records and and extra blank column between fields.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  • Add net.sf.jasperreports.export.xls.remove.empty.space.between.columns and net.sf.jasperreports.export.xls.remove.empty.space.between.rows properties to report template.

net.sf.jasperreports.export.xls.remove.empty.space.between.columns - Specifies whether the empty spacer columns should be removed or not.

net.sf.jasperreports.export.xls.remove.empty.space.between.rows - Specifies whether the empty spacer rows should be removed or not.

The 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"/>

The information about configuration properties is here.

  • You can set isRemoveLineWhenBlank and isBlankWhenNull for textField element for hiding blank row.

The sample how to remove the whole line if the current textField is empty:

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

In case this design:

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

you will have a space between any two rows.

In case this design (textField height is equal to the Band's height): the textfield height is equal to the band's height

the each line will be exactly under the other.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...