![](/img/trans.png)
[英]Displaying Multiple Tables in a Page in Jasper Reports using ireports/Jasper Assistant
[英]Additional page for Jasper reports
我想為使用Jasper生成的每個報告添加一個“免責聲明”頁面。 這將是一個包含靜態文本的頁面,並且每個報告都相同。 但是需要將其生成為報告的最后一頁或第一頁。 有沒有辦法創建這樣的解決方案?
如果使用Java ,則可以使用Batch Mode Export 。 您可以借助JASPER_PRINT_LIST參數設置JasperPrint的列表,以從多個模板生成一個報告。
您可以將帶有免責聲明的報告添加到所有報告中。 您無需修改jrxml文件。
例如,我們有報告( singleReport1.jrxml )和免責聲明( disclaimer.jrxml )。
報告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="singleReport1" language="groovy" pageWidth="297" pageHeight="421" whenNoDataType="AllSectionsNoDetail" columnWidth="257" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<title>
<band height="175" splitType="Stretch">
<staticText>
<reportElement x="8" y="46" width="241" height="83"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14"/>
</textElement>
<text><![CDATA[The First Report]]></text>
</staticText>
</band>
</title>
</jasperReport>
免責聲明代碼為:
<?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="disclaimer" language="groovy" pageWidth="297" pageHeight="421" whenNoDataType="AllSectionsNoDetail" columnWidth="257" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<title>
<band height="175" splitType="Stretch">
<staticText>
<reportElement x="8" y="46" width="241" height="83"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14"/>
</textElement>
<text><![CDATA[The disclaimer]]></text>
</staticText>
</band>
</title>
</jasperReport>
iReport中第一個報告的設計是:
免責聲明頁面的設計是:
Java代碼:
public static void testReport() throws JRException {
JasperReport jasperReport1 = JasperCompileManager.compileReport(reportSourceReport1);
JasperReport jasperDisclaimer = JasperCompileManager.compileReport(reportSourceDisclaimer);
JasperPrint jasperPrintReport1 = JasperFillManager.fillReport(jasperReport1, null, new JREmptyDataSource());
JasperPrint jasperPrintDisclaimer = JasperFillManager.fillReport(jasperDisclaimer, null, new JREmptyDataSource());
List<JasperPrint> jasperPrints = Lists.newArrayList();
jasperPrints.addAll(Arrays.asList(jasperPrintReport1, jasperPrintDisclaimer));
JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrints);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, fileName);
exporter.exportReport();
}
結果將是(在Adobe Reader中打開的pdf文件):
注意事項 :
有關批處理模式導出的更多信息
您可以添加摘要帶; 它會顯示在報告的末尾。 如果要在iReport中布置報告,請右鍵單擊“報告檢查器”中的摘要區域並將其添加到報告中,然后在“報告檢查器”中單擊報告名稱以打開“屬性”窗口。 單擊新頁面上的摘要復選框。
如果您自己編寫代碼,則看起來像:
<jasperReport xmlns="..." isSummaryNewPage="true">
...
<summary>
<band height="50">
...
</band>
</summary>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.