【发布时间】:2024-01-15 10:36:01
【问题描述】:
我在 Jaspersoft Studio 中使用 Jasper Reports 6.0.1。
我有一份带有子报告的报告。子报表正确地从主报表中获取数据集,其值: - 细绳 - 双重
我在报告中正确显示双精度值时遇到问题。 所以 Json 包含如下值:
'doubleValue':'0.431'
在子报表中正确定义了字段“doubleValue”:
<field name="doubleValue" class="java.lang.Double">
<fieldDescription><![CDATA[doubleValue]]></fieldDescription>
</field>
报告中似乎正确使用了“doubleValue”:
<textField pattern="#0.00">
<reportElement x="690" y="0" width="75" height="30" uuid="d265ebec-6fa7-421e-8d58-c7f2d32eea6b">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<box>
<topPen lineWidth="0.1"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement>
<font size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{doubleValue}]]></textFieldExpression>
</textField>
doubleValue 在输出中的格式似乎正确: '3.00'
但是: 字段值的来源是 3.41。 所以我对这些值进行了深入检查,无论小数点分隔符后面是什么,所有值都被格式化为“x.00”。
请帮帮我,我做错了什么?
我需要将数据正确导出到 XLSX(因此它知道单元格中有一个数字),为此我使用以下选项:
<property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
【问题讨论】:
-
我已经尝试过将您的模式导出到 excel,我对此没有任何问题(jasper 报告 v6)。此外请注意,在 excel 中,实际值在单元格中(因此为 3.414545,并且只有 excel 中的格式设置为显示 2 个数字(个性化格式 #.00)
标签: json jasper-reports double number-formatting