带有手动标记的 pdf 报告抛出 EmptyStackException
The pdf report with manual tagging throws EmptyStackException
我有 spring webapp,我在其中使用 JasperReports 生成一些基本的数据库查询报告并导出为 pdf。
我已经尝试以编程方式添加标签而不是使用 jrxml,使用 dynamic-jasper 并且遇到了不同的问题。我的 jrxml 文件几乎是 Jaspersoft Studio 中 tabular-report.jrxml 示例的副本。如果您需要查看其他内容来解决这个问题,请告诉我,此时任何帮助都将不胜感激。
找到这个但没有解决方案:https://community.jaspersoft.com/questions/1112221/error-manulal-tagging-table-pdf-export
这是我的 jrxml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ....>
<style>....
</style>
<queryString>
This works, deleted because its sensitive.
</queryString>
<field name="last_login" class="java.sql.Timestamp"/>
<field name="first_name" class="java.lang.String"/>
<field name="middle_name" class="java.lang.String"/>
<field name="last_name" class="java.lang.String"/>
<field name="IAL" class="java.lang.Integer"/>
<field name="xid" class="java.lang.String"/>
<field name="email" class="java.lang.String"/>
<title>
<band height="45">
<staticText>
<reportElement style="reportTitleStyle" positionType="Float" x="0" y="0" width="595" height="30">
<property name="net.sf.jasperreports.export.pdf.tag.h1" value="full"/>
</reportElement>
<textElement/>
<text><![CDATA[User Login Report]]></text>
</staticText>
<textField>
<reportElement style="subTitleStyle" positionType="Float" x="0" y="30" width="595" height="15">
<property name="net.sf.jasperreports.export.pdf.tag.h2" value="full"/>
</reportElement>
<textElement/>
<textFieldExpression>
<![CDATA["This report was generated at " + new java.util.Date()]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="30">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="defaultHeaderStyle" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="95" height="30" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.table" value="start"/>
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.rowspan" value="2"/>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA["Last Login"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="defaultHeaderStyle" positionType="Float" stretchType="RelativeToTallestObject" x="95" y="0" width="83" height="30" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.rowspan" value="2"/>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA["First Name"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="defaultHeaderStyle" positionType="Float" stretchType="RelativeToTallestObject" x="178" y="0" width="59" height="30" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.rowspan" value="2"/>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA["Middle Name"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="defaultHeaderStyle" positionType="Float" stretchType="RelativeToTallestObject" x="237" y="0" width="83" height="30" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.rowspan" value="2"/>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA["Last Name"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="defaultHeaderStyle" positionType="Float" stretchType="RelativeToTallestObject" x="320" y="0" width="35" height="30" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.rowspan" value="2"/>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA["IAL"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="defaultHeaderStyle" positionType="Float" stretchType="RelativeToTallestObject" x="355" y="0" width="59" height="30" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.rowspan" value="2"/>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA["XID"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="defaultHeaderStyle" positionType="Float" stretchType="RelativeToTallestObject" x="414" y="0" width="141" height="30" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.rowspan" value="2"/>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA["Email"]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<detail>
<band height="15" splitType="Immediate">
<frame>
<reportElement x="0" y="0" width="555" height="15">
<property name="net.sf.jasperreports.export.pdf.tag.tr" value="full"/>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="timeStampColumnStyle" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="95" height="15" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<textFieldExpression><![CDATA[$F{last_login}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="columnStyle" positionType="Float" stretchType="RelativeToTallestObject" x="95" y="0" width="83" height="15" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<textFieldExpression><![CDATA[$F{first_name}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="columnStyle" positionType="Float" stretchType="RelativeToTallestObject" x="178" y="0" width="59" height="15" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<textFieldExpression><![CDATA[$F{middle_name}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="columnStyle" positionType="Float" stretchType="RelativeToTallestObject" x="237" y="0" width="83" height="15" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<textFieldExpression><![CDATA[$F{last_name}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="columnStyle" positionType="Float" stretchType="RelativeToTallestObject" x="320" y="0" width="35" height="15" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<textFieldExpression><![CDATA[$F{IAL}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="columnStyle" positionType="Float" stretchType="RelativeToTallestObject" x="355" y="0" width="59" height="15" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<textFieldExpression><![CDATA[$F{xid}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="columnStyle" positionType="Float" stretchType="RelativeToTallestObject" x="414" y="0" width="141" height="15" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.table" value="end"/>
</reportElement>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{email}]]></textFieldExpression>
</textField>
</frame>
</band>
</detail>
</jasperReport>
错误:
java.util.EmptyStackException
at java.util.Stack.peek(Stack.java:102)
at net.sf.jasperreports.engine.export.JRPdfExporterTagHelper.createTrStartTag(JRPdfExporterTagHelper.java:664)
at net.sf.jasperreports.engine.export.JRPdfExporterTagHelper.createStartTags(JRPdfExporterTagHelper.java:589)
at net.sf.jasperreports.engine.export.JRPdfExporterTagHelper.startElement(JRPdfExporterTagHelper.java:499)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:1241)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:1210)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:1074)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:691)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
错误是由 net.sf.jasperreports.export.pdf.tag.table=end
属性 引起的,它是在您报告的详细信息区域中的一个元素上设置的。查询结果中的每条记录都会重复详细信息带,因此在详细信息带中设置 net.sf.jasperreports.export.pdf.tag.table=end
没有意义。
属性 应设置在仅在 table/page 末尾打印一次的元素上,例如在页脚区域中:
<pageFooter>
<band height="1">
<textField>
<reportElement x="0" y="0" width="100" height="1">
<property name="net.sf.jasperreports.export.pdf.tag.table" value="end"/>
</reportElement>
<textFieldExpression>""</textFieldExpression>
</textField>
</band>
</pageFooter>
我有 spring webapp,我在其中使用 JasperReports 生成一些基本的数据库查询报告并导出为 pdf。
我已经尝试以编程方式添加标签而不是使用 jrxml,使用 dynamic-jasper 并且遇到了不同的问题。我的 jrxml 文件几乎是 Jaspersoft Studio 中 tabular-report.jrxml 示例的副本。如果您需要查看其他内容来解决这个问题,请告诉我,此时任何帮助都将不胜感激。
找到这个但没有解决方案:https://community.jaspersoft.com/questions/1112221/error-manulal-tagging-table-pdf-export
这是我的 jrxml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ....>
<style>....
</style>
<queryString>
This works, deleted because its sensitive.
</queryString>
<field name="last_login" class="java.sql.Timestamp"/>
<field name="first_name" class="java.lang.String"/>
<field name="middle_name" class="java.lang.String"/>
<field name="last_name" class="java.lang.String"/>
<field name="IAL" class="java.lang.Integer"/>
<field name="xid" class="java.lang.String"/>
<field name="email" class="java.lang.String"/>
<title>
<band height="45">
<staticText>
<reportElement style="reportTitleStyle" positionType="Float" x="0" y="0" width="595" height="30">
<property name="net.sf.jasperreports.export.pdf.tag.h1" value="full"/>
</reportElement>
<textElement/>
<text><![CDATA[User Login Report]]></text>
</staticText>
<textField>
<reportElement style="subTitleStyle" positionType="Float" x="0" y="30" width="595" height="15">
<property name="net.sf.jasperreports.export.pdf.tag.h2" value="full"/>
</reportElement>
<textElement/>
<textFieldExpression>
<![CDATA["This report was generated at " + new java.util.Date()]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="30">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="defaultHeaderStyle" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="95" height="30" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.table" value="start"/>
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.rowspan" value="2"/>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA["Last Login"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="defaultHeaderStyle" positionType="Float" stretchType="RelativeToTallestObject" x="95" y="0" width="83" height="30" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.rowspan" value="2"/>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA["First Name"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="defaultHeaderStyle" positionType="Float" stretchType="RelativeToTallestObject" x="178" y="0" width="59" height="30" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.rowspan" value="2"/>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA["Middle Name"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="defaultHeaderStyle" positionType="Float" stretchType="RelativeToTallestObject" x="237" y="0" width="83" height="30" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.rowspan" value="2"/>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA["Last Name"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="defaultHeaderStyle" positionType="Float" stretchType="RelativeToTallestObject" x="320" y="0" width="35" height="30" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.rowspan" value="2"/>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA["IAL"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="defaultHeaderStyle" positionType="Float" stretchType="RelativeToTallestObject" x="355" y="0" width="59" height="30" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.rowspan" value="2"/>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA["XID"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="defaultHeaderStyle" positionType="Float" stretchType="RelativeToTallestObject" x="414" y="0" width="141" height="30" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.rowspan" value="2"/>
</reportElement>
<textElement/>
<textFieldExpression><![CDATA["Email"]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<detail>
<band height="15" splitType="Immediate">
<frame>
<reportElement x="0" y="0" width="555" height="15">
<property name="net.sf.jasperreports.export.pdf.tag.tr" value="full"/>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="timeStampColumnStyle" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="95" height="15" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<textFieldExpression><![CDATA[$F{last_login}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="columnStyle" positionType="Float" stretchType="RelativeToTallestObject" x="95" y="0" width="83" height="15" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<textFieldExpression><![CDATA[$F{first_name}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="columnStyle" positionType="Float" stretchType="RelativeToTallestObject" x="178" y="0" width="59" height="15" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<textFieldExpression><![CDATA[$F{middle_name}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="columnStyle" positionType="Float" stretchType="RelativeToTallestObject" x="237" y="0" width="83" height="15" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<textFieldExpression><![CDATA[$F{last_name}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="columnStyle" positionType="Float" stretchType="RelativeToTallestObject" x="320" y="0" width="35" height="15" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<textFieldExpression><![CDATA[$F{IAL}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="columnStyle" positionType="Float" stretchType="RelativeToTallestObject" x="355" y="0" width="59" height="15" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<textFieldExpression><![CDATA[$F{xid}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="columnStyle" positionType="Float" stretchType="RelativeToTallestObject" x="414" y="0" width="141" height="15" isPrintWhenDetailOverflows="true">
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.table" value="end"/>
</reportElement>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{email}]]></textFieldExpression>
</textField>
</frame>
</band>
</detail>
</jasperReport>
错误:
java.util.EmptyStackException
at java.util.Stack.peek(Stack.java:102)
at net.sf.jasperreports.engine.export.JRPdfExporterTagHelper.createTrStartTag(JRPdfExporterTagHelper.java:664)
at net.sf.jasperreports.engine.export.JRPdfExporterTagHelper.createStartTags(JRPdfExporterTagHelper.java:589)
at net.sf.jasperreports.engine.export.JRPdfExporterTagHelper.startElement(JRPdfExporterTagHelper.java:499)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:1241)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:1210)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:1074)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:691)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
错误是由 net.sf.jasperreports.export.pdf.tag.table=end
属性 引起的,它是在您报告的详细信息区域中的一个元素上设置的。查询结果中的每条记录都会重复详细信息带,因此在详细信息带中设置 net.sf.jasperreports.export.pdf.tag.table=end
没有意义。
属性 应设置在仅在 table/page 末尾打印一次的元素上,例如在页脚区域中:
<pageFooter>
<band height="1">
<textField>
<reportElement x="0" y="0" width="100" height="1">
<property name="net.sf.jasperreports.export.pdf.tag.table" value="end"/>
</reportElement>
<textFieldExpression>""</textFieldExpression>
</textField>
</band>
</pageFooter>