<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="test" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0ef33a9d-fd2b-46cc-9ec4-c6906db8097b">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="testNumber" class="java.lang.Double" isForPrompting="false">
<defaultValueExpression><![CDATA[new Double(10000.23445)]]></defaultValueExpression>
</parameter>
<title>
<band height="57" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="373" height="57" uuid="2f795f8a-43fa-4b89-a173-76854a13ba48"/>
<textElement markup="html"/>
<textFieldExpression><![CDATA["Just use a textField and string concat the other text a " + java.text.NumberFormat.getNumberInstance().format($P{testNumber}) + " as you see you can even format it and remeber if you set as html you can break line and <b>bold</b> text"]]></textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
1 回答
在文本上使用
textField
然后使用字符串连接,当需要数字格式时使用NumberFormat API或DecimalFormat API如果你需要断行,设置粗体文本你可以使用html来实现这一点,方法是在
textElement
上设置markup="html"
Example
Output