无法在碧玉报告中查看列标题中的文本
Unable to view text in columnHeaders in jasper report
我正在尝试创建一个显示已处理呼叫列表的 jasper 报告(pdf 格式)。正在创建报告,但未显示标题。我已尝试更改样式,但似乎对这种情况没有任何效果。
我为此使用以下库
- jasper-compiler-jdt-5.5.15.jar
- jasperreports-6.2.0.jar
- jasperreports-fonts-6.0.0.jar
- itext-2.1.7.jar
- itextpdf-5.5.10.jar
以下是 jrxml 文件的一部分
<?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="StockReport" pageWidth="1200" pageHeight="600" columnWidth="50" leftMargin="35" rightMargin="35" topMargin="50" bottomMargin="40">
<parameter name="Title" class="java.lang.String"/>
<field name="id" class="java.lang.Long"/>
<field name="dateTime" class="java.util.Date"/>
--------------------------------------------------
<title>
<band height="50" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="0" y="5" width="960" height="30"/>
<textElement textAlignment="Center">
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{Title}]]>
</textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="20" splitType="Stretch">
<textField>
<reportElement mode="Opaque" x="55" y="5" width="1000" height="15" forecolor="#FFFFFF" backcolor="#8c8c8c"/>
<textElement textAlignment="Center">
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["Daily Reports"]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="20" splitType="Stretch">
<staticText>
<reportElement mode="Opaque" x="55" y="4" width="30" height="15" forecolor="#FFFFFF" backcolor="#b30000"/>
<textElement textAlignment="Left">
<font isBold = "true"/>
</textElement>
<text>
<![CDATA["Record Id"]]>
</text>
</staticText>
<staticText>
<reportElement positionType="Float" mode="Opaque" x="85" y="4" width="100" height="15" forecolor="#FFFFFF" backcolor="#b30000"/>
<textElement>
<font isBold = "true"/>
</textElement>
<text>
<![CDATA["Date/Time"]]>
</text>
</staticText>
-------------------------------------------
</band>
</columnHeader>
<detail>
<band height="80" splitType="Stretch">
<textField>
<reportElement x="65" y="4" width="15" height="60"/>
<textElement textAlignment="Left"/>
<textFieldExpression class="java.lang.Long"><![CDATA[$F{id}]]>
</textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement positionType="Float" x="95" y="4" width="90" height="60"/>
<textElement/>
<textFieldExpression class="java.util.Date"><![CDATA[$F{dateTime}]]></textFieldExpression>
</textField>
-----------------------------------------------------
这是我的 jrxml 文件。
除了第 headers 列外,所有数据都正确显示。我不明白问题出在哪里。我也收到以下警告
WARN [net.sf.jasperreports.engine.export.PdfGlyphRenderer] -------- Unpatched iText found, cannot use glyph rendering
生成的pdf截图(部分细节被刮掉)
任何帮助将不胜感激。
我没有使用 iReport 工具。目前,同样的使用仅限于我们的团队。请提出除此之外的解决方案。
提前致谢。
感谢所有帮助过的人。
问题与 itext 无关,与元素样式有关。
更新后的代码如下
<?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="StockReport" pageWidth="1200" pageHeight="600" columnWidth="50" leftMargin="35" rightMargin="35" topMargin="50" bottomMargin="40">
<parameter name="Title" class="java.lang.String"/>
<field name="id" class="java.lang.Long"/>
<field name="dateTime" class="java.util.Date"/>
--------------------
<title>
<band height="50" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="0" y="5" width="960" height="30"/>
<textElement textAlignment="Center">
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{Title}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="20" splitType="Stretch">
<textField>
<reportElement mode="Opaque" x="55" y="5" width="1000" height="15" forecolor="#FFFFFF" backcolor="#8c8c8c"/>
<textElement textAlignment="Center">
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["Daily Reports"]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height = "23">
<staticText>
<reportElement mode = "Opaque" x = "55" y = "3"
width = "1000" height = "15" backcolor = "#70A9A9" />
<box>
<bottomPen lineWidth = "1.0" lineColor = "#CCCCCC" />
</box>
<textElement />
<text><![CDATA[]]> </text>
</staticText>
-------------------------------------
<staticText>
<reportElement x = "85" y = "3" width = "100" height = "15" />
<textElement textAlignment = "Center" verticalAlignment = "Middle">
<font isBold = "true" />
</textElement>
<text><![CDATA[Date/Time]]></text>
</staticText>
<staticText>
<reportElement x = "55" y = "3" width = "30" height = "15" />
<textElement textAlignment = "Center" verticalAlignment = "Middle">
<font isBold = "true" />
</textElement>
<text><![CDATA[#Id]]></text>
</staticText>
</band>
我只是添加了一个元素,没有文本内容用作列 header 横幅,并通过指定位置在其顶部添加了 header 文本。
我不确定这背后的逻辑。至于警告,Unpatched iText found, cannot use glyph rendering
仍然存在。我不确定如何解决这个问题,但上面引用的内容帮助我解决了最初的问题。如果有人遇到类似问题,我希望这会有所帮助。
再次感谢所有提供帮助的人,正如上面评论中所建议的那样,我将尝试对更新的库执行相同的操作,如果它有助于解决问题,我肯定会用更新的结果编辑我的 post。
我正在尝试创建一个显示已处理呼叫列表的 jasper 报告(pdf 格式)。正在创建报告,但未显示标题。我已尝试更改样式,但似乎对这种情况没有任何效果。
我为此使用以下库
- jasper-compiler-jdt-5.5.15.jar
- jasperreports-6.2.0.jar
- jasperreports-fonts-6.0.0.jar
- itext-2.1.7.jar
- itextpdf-5.5.10.jar
以下是 jrxml 文件的一部分
<?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="StockReport" pageWidth="1200" pageHeight="600" columnWidth="50" leftMargin="35" rightMargin="35" topMargin="50" bottomMargin="40">
<parameter name="Title" class="java.lang.String"/>
<field name="id" class="java.lang.Long"/>
<field name="dateTime" class="java.util.Date"/>
--------------------------------------------------
<title>
<band height="50" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="0" y="5" width="960" height="30"/>
<textElement textAlignment="Center">
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{Title}]]>
</textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="20" splitType="Stretch">
<textField>
<reportElement mode="Opaque" x="55" y="5" width="1000" height="15" forecolor="#FFFFFF" backcolor="#8c8c8c"/>
<textElement textAlignment="Center">
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["Daily Reports"]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="20" splitType="Stretch">
<staticText>
<reportElement mode="Opaque" x="55" y="4" width="30" height="15" forecolor="#FFFFFF" backcolor="#b30000"/>
<textElement textAlignment="Left">
<font isBold = "true"/>
</textElement>
<text>
<![CDATA["Record Id"]]>
</text>
</staticText>
<staticText>
<reportElement positionType="Float" mode="Opaque" x="85" y="4" width="100" height="15" forecolor="#FFFFFF" backcolor="#b30000"/>
<textElement>
<font isBold = "true"/>
</textElement>
<text>
<![CDATA["Date/Time"]]>
</text>
</staticText>
-------------------------------------------
</band>
</columnHeader>
<detail>
<band height="80" splitType="Stretch">
<textField>
<reportElement x="65" y="4" width="15" height="60"/>
<textElement textAlignment="Left"/>
<textFieldExpression class="java.lang.Long"><![CDATA[$F{id}]]>
</textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement positionType="Float" x="95" y="4" width="90" height="60"/>
<textElement/>
<textFieldExpression class="java.util.Date"><![CDATA[$F{dateTime}]]></textFieldExpression>
</textField>
-----------------------------------------------------
这是我的 jrxml 文件。
除了第 headers 列外,所有数据都正确显示。我不明白问题出在哪里。我也收到以下警告
WARN [net.sf.jasperreports.engine.export.PdfGlyphRenderer] -------- Unpatched iText found, cannot use glyph rendering
生成的pdf截图(部分细节被刮掉)
任何帮助将不胜感激。
我没有使用 iReport 工具。目前,同样的使用仅限于我们的团队。请提出除此之外的解决方案。
提前致谢。
感谢所有帮助过的人。
问题与 itext 无关,与元素样式有关。
更新后的代码如下
<?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="StockReport" pageWidth="1200" pageHeight="600" columnWidth="50" leftMargin="35" rightMargin="35" topMargin="50" bottomMargin="40">
<parameter name="Title" class="java.lang.String"/>
<field name="id" class="java.lang.Long"/>
<field name="dateTime" class="java.util.Date"/>
--------------------
<title>
<band height="50" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="0" y="5" width="960" height="30"/>
<textElement textAlignment="Center">
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{Title}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="20" splitType="Stretch">
<textField>
<reportElement mode="Opaque" x="55" y="5" width="1000" height="15" forecolor="#FFFFFF" backcolor="#8c8c8c"/>
<textElement textAlignment="Center">
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["Daily Reports"]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height = "23">
<staticText>
<reportElement mode = "Opaque" x = "55" y = "3"
width = "1000" height = "15" backcolor = "#70A9A9" />
<box>
<bottomPen lineWidth = "1.0" lineColor = "#CCCCCC" />
</box>
<textElement />
<text><![CDATA[]]> </text>
</staticText>
-------------------------------------
<staticText>
<reportElement x = "85" y = "3" width = "100" height = "15" />
<textElement textAlignment = "Center" verticalAlignment = "Middle">
<font isBold = "true" />
</textElement>
<text><![CDATA[Date/Time]]></text>
</staticText>
<staticText>
<reportElement x = "55" y = "3" width = "30" height = "15" />
<textElement textAlignment = "Center" verticalAlignment = "Middle">
<font isBold = "true" />
</textElement>
<text><![CDATA[#Id]]></text>
</staticText>
</band>
我只是添加了一个元素,没有文本内容用作列 header 横幅,并通过指定位置在其顶部添加了 header 文本。
我不确定这背后的逻辑。至于警告,Unpatched iText found, cannot use glyph rendering
仍然存在。我不确定如何解决这个问题,但上面引用的内容帮助我解决了最初的问题。如果有人遇到类似问题,我希望这会有所帮助。
再次感谢所有提供帮助的人,正如上面评论中所建议的那样,我将尝试对更新的库执行相同的操作,如果它有助于解决问题,我肯定会用更新的结果编辑我的 post。