赏金6天后到期。回答此问题可获得+50声望奖励。konstantin kim想引起更多的注意**这个问题。
我正在写一本抽象书的报告。它包括toc(目录)和子报表(jrxml):
<group name="cover">
<groupHeader>
<part evaluationTime="Report" uuid="56ab525c-754f-4f48-a52c-7cc23934be3d">
<property name="net.sf.jasperreports.bookmarks.data.source.parameter" value="REPORT_DATA_SOURCE"/>
<p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts"
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd">
<subreportParameter name="REPORT_DATA_SOURCE">
<subreportParameterExpression>
<![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("combinedReport")]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression><![CDATA[$P{tocReport}]]></subreportExpression>
</p:subreportPart>
</part>
</groupHeader>
</group>
<detail>
<part uuid="9431bc63-c820-403c-a317-e7ffe3295dcf">
<p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts"
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd">
<subreportParameter name="REPORT_DATA_SOURCE">
<subreportParameterExpression>
<![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("combinedReport")]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression><![CDATA[$P{subreport}]]></subreportExpression>
</p:subreportPart>
</part>
</detail>
我已将超链接添加到子报表中的文本字段:
<textField textAdjust="StretchHeight" hyperlinkType="LocalAnchor" bookmarkLevel="1">
<reportElement x="0" y="0" width="280" height="30" uuid="8a8b1b38-78d3-4ab5-a728-6c0f2796371d"/>
<textElement>
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Bla bla"]]></textFieldExpression>
<anchorNameExpression><![CDATA["Bla bla"]]></anchorNameExpression>
</textField>
但是目录是空的,只在页面顶部显示静态文本“目录”。以下是我编写报告的方法(简短版本):
subReport = JasperCompileManager.compileReport(jrxmlContentOutputPath);
tocReport = JasperCompileManager.compileReport(jrxmlTocOutputPath);
InputStream templateIs = ReportPdfService.class.getClassLoader().getResourceAsStream("jasper-reports/Abstract_Book.jrxml");
Map<String, Object> parameters = new HashMap<>();
parameters.put("REPORT_DATA_SOURCE", jsonDataSource);
parameters.put("subreport", subReport);
parameters.put("tocReport", tocReport);
JasperReport report = JasperCompileManager.compileReport(templateIs);
JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters);
JasperExportManager.exportReportToPdfFile(jasperPrint, outputReportPdfPath);
我认为问题是超链接,它是在toc编译后创建的。但什么都不管用。
暂无答案!
目前还没有任何答案,快来回答吧!