I am exporting a report I created to a CSV file. The export goes fine but the formatting is off and the variable that I have displaying in a text field doesn't show up at all.
The formatting isn't aligning columns properly and it's re-sizing them so that the values don't show up unless you expand the column. Also, the text field displaying my variable $V{reportTotal} is set as a BigDecimal and formatted for currency. This text field doesn't show anything.
Everything looks great when I choose PDF output. What can I do to fix these formatting problems for CSV output?
You can try this sample:
<jasperReport ...>
...
<field name="ORDERS_ORDERID" class="java.lang.Integer"/>
<field name="ORDERS_CUSTOMERID" class="java.lang.String"/>
<field name="ORDERS_FREIGHT" class="java.math.BigDecimal"/>
...
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{ORDERS_FREIGHT}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="100" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{ORDERS_ORDERID}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="200" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{ORDERS_CUSTOMERID}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
The result is:
32.38,10248,VINET
11.61,10249,TOMSP
65.83,10250,HANAR
41.34,10251,VICTE
51.3,10252,SUPRD
55.09,10260,OTTIK
3.05,10261,QUEDE
48.29,10262,RATTC
I think you should check your result csv
file in basic text viewer/editor (for example, Notepad++ or Notepad on Windows).