ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

为什么编译的动态报告(.jasper)无法反映更改?

2019-11-18 07:09:50  阅读:301  来源: 互联网

标签:export-to-excel jasper-reports dynamic-reports java


我正在使用动态报表库创建一个Jasper报表.
我正在尝试编译动态报告,以在以后使用编译后的版本.但是我的报告的编译版本没有反映出动态报告所做的更改

这是我的代码:

JasperReportBuilder report = report();
report.setTemplateDesign(new File("Template.jrxml"));
report.setParameters(parameters);

List<TextColumnBuilder> lsColumns = getDRColumnsFromRecordset(rs);
for (TextColumnBuilder tcbColumn : lsColumns) {
    report.addColumn(tcbColumn);
}
report.ignorePageWidth();
report.ignorePagination();
report.setDataSource(rs);
report.toXlsx();

//At the end, i compile the dynamic report
File compiledTemplate = new File("CompiledTemplate.jasper");
JasperCompileManager.compileReportToFile(report.toJasperDesign(), compiledTemplate.getPath());

在上面的代码中,它可以正确生成(当我运行.toXlsx()时)

但是,在应用程序的另一点,我检查编译的模板是否存在.如果存在,我将使用已编译的模板来生成报告.

但是,当我尝试使用编译版本生成模板时,它返回空.

它是在没有记录集列的情况下生成的-我在上面的代码中动态添加了这些记录集.

更新状态
2016年8月31日
我的情况是:我有一个包含动态输出的过程(取决于您收到的参数).因此,例如,当过程接收@Cod = 1参数时,它将具有特定的SQL输出.
我希望第一次运行动态报告时,根据过程输出生成已编译的报告(.jasper).
而且在以后的时间里,我可以重用已编译的报告(.jasper)来仅使用它来生成新报告.

我解决了部分问题.当它第二次运行时,jrxml模板中没有SQL.因此,我在模板jrxml中插入了以下代码:


    <parameter name="QUERY" class="java.lang.String" isForPrompting="false"/>
    <queryString>
        <![CDATA[$P!{QUERY}]]>
    </queryString>

并且我在程序中插入了以下代码(使用DynamicReports中生成的.jasper时):

JasperReport jasperReport = (JasperReport) JRLoader.loadObject(compiledTemplate);        
parameters.put("QUERY", "dbo.pr_test_procedure @Cod=" + parameters.get("COD")); 
        JasperPrint jasperPrint
                = JasperFillManager.fillReport(jasperReport,
                        parameters,
                        conn);

现在,报告将带来查询结果(如动态报告中所述).
现在,问题是另一个:它不显示列标题.仅显示记录.
当我通过动态报告生成时,同时显示两者.使用编译的碧玉生成时,仅显示记录.

我现在的结果:
这是动态报告中的报告(不进行编译):https://s21.postimg.org/arh0w5isn/relatorio_1.jpg
这是Jasper https://s17.postimg.org/iozct8mwf/relatorio_2.jpg中生成的编译后的报告

这是已编译文件的jrxml:


<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.1.1.final using JasperReports Library version 6.1.1  -->
<!-- 2016-08-31T14:20:33 -->
<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="Template_Basico" pageWidth="1392" pageHeight="595" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="1352" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isIgnorePagination="true" uuid="8a465670-cc4a-4270-965f-8efb86e33b71">
    <property name="template.engine" value="tabular_template"/>
    <property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
    <property name="net.sf.jasperreports.export.xls.show.gridlines" value="false"/>
    <template><![CDATA[$P{PATH_PADRAODSM} + "/" + "Template_Basico.jrtx"]]></template>
    <style name="TabelaCabecalho" mode="Opaque" backcolor="#4692F0" scaleImage="FillFrame" isBlankWhenNull="true" fontName="SansSerif" fontSize="13" isBold="true">
        <pen lineStyle="Solid" lineColor="#000000"/>
        <box>
            <topPen lineWidth="1.0"/>
            <leftPen lineWidth="1.0"/>
            <bottomPen lineWidth="1.0"/>
            <rightPen lineWidth="1.0"/>
        </box>
    </style>
    <style name="style_36_" forecolor="#000000" isBlankWhenNull="true" fontName="SansSerif" fontSize="10">
        <box topPadding="2" leftPadding="2" bottomPadding="2" rightPadding="2"/>
    </style>
    <style name="Fonte" pattern="" isBlankWhenNull="true" fontName="Verdana" fontSize="11" isBold="false"/>
    <subDataset name="tableDataset" uuid="73560e0d-a48c-4cef-a6c7-dc2799080847">
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
        <queryString>
            <![CDATA[]]>
        </queryString>
    </subDataset>
    <scriptlet name="DYNAMICREPORTS" class="net.sf.dynamicreports.jasper.base.JasperScriptlet"/>
    <parameter name="CODPEDIDO" class="java.lang.Integer">
        <parameterDescription><![CDATA[Código do pedido do relatório]]></parameterDescription>
        <defaultValueExpression><![CDATA[90200]]></defaultValueExpression>
    </parameter>
    <parameter name="PATH" class="java.lang.String" isForPrompting="false">
        <parameterDescription><![CDATA[]]></parameterDescription>
        <defaultValueExpression><![CDATA["/home/diego.queres/Desenv/Relatórios Clientes/PadraoDSM_Templates"]]></defaultValueExpression>
    </parameter>
    <parameter name="TITULO" class="java.lang.String">
        <defaultValueExpression><![CDATA["Relatório"]]></defaultValueExpression>
    </parameter>
    <parameter name="LOGOTIPO_1" class="java.lang.String" isForPrompting="false">
        <parameterDescription><![CDATA[]]></parameterDescription>
        <defaultValueExpression><![CDATA["logo-vagas.png"]]></defaultValueExpression>
    </parameter>
    <parameter name="PATH_PADRAODSM" class="java.lang.String">
        <defaultValueExpression><![CDATA["/home/diego.queres/Desenv/Relatórios Clientes/PadraoDSM_Templates"]]></defaultValueExpression>
    </parameter>
    <parameter name="QUERY" class="java.lang.String" isForPrompting="false"/>
    <parameter name="CUSTOM_VALUES" class="net.sf.dynamicreports.jasper.base.JasperCustomValues"/>
    <queryString>
        <![CDATA[$P!{QUERY}]]>
    </queryString>
    <field name="Codigo do candidato" class="java.lang.Integer">
        <fieldDescription><![CDATA[Codigo do candidato]]></fieldDescription>
    </field>
    <field name="Nome" class="java.lang.String">
        <fieldDescription><![CDATA[Nome]]></fieldDescription>
    </field>
    <field name="E-mail" class="java.lang.String">
        <fieldDescription><![CDATA[E-mail]]></fieldDescription>
    </field>
    <field name="Idade" class="java.lang.Integer">
        <fieldDescription><![CDATA[Idade]]></fieldDescription>
    </field>
    <field name="Telefone(s) Contato" class="java.lang.String">
        <fieldDescription><![CDATA[Telefone(s) Contato]]></fieldDescription>
    </field>
    <field name="Cidade e Estado" class="java.lang.String">
        <fieldDescription><![CDATA[Cidade e Estado]]></fieldDescription>
    </field>
    <field name="Tipo de Formação 1" class="java.lang.String">
        <fieldDescription><![CDATA[Tipo de Formação 1]]></fieldDescription>
    </field>
    <field name="Formação 1" class="java.lang.String">
        <fieldDescription><![CDATA[Formação 1]]></fieldDescription>
    </field>
    <field name="Instituição 1" class="java.lang.String">
        <fieldDescription><![CDATA[Instituição 1]]></fieldDescription>
    </field>
    <field name="Tipo de Formação 2" class="java.lang.String">
        <fieldDescription><![CDATA[Tipo de Formação 2]]></fieldDescription>
    </field>
    <field name="Formação 2" class="java.lang.String">
        <fieldDescription><![CDATA[Formação 2]]></fieldDescription>
    </field>
    <field name="Instituição 2" class="java.lang.String">
        <fieldDescription><![CDATA[Instituição 2]]></fieldDescription>
    </field>
    <field name="Histórico profissional (2 últimas empresas)" class="java.lang.String">
        <fieldDescription><![CDATA[Histórico profissional (2 últimas empresas)]]></fieldDescription>
    </field>
    <title>
        <band height="76" splitType="Stretch">
            <image scaleImage="RetainShape">
                <reportElement x="22" y="32" width="100" height="40" uuid="6047dd6f-0536-4689-bafa-083c4dad3a84"/>
                <imageExpression><![CDATA[$P{PATH_PADRAODSM} + "/" + $P{LOGOTIPO_1}]]></imageExpression>
            </image>
            <textField>
                <reportElement x="140" y="40" width="800" height="25" uuid="0282ba00-7352-4d77-bb8b-c0bb0ba0e585"/>
                <textElement verticalAlignment="Bottom">
                    <font size="16"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{TITULO}]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <pageHeader>
        <band height="36">
            <line>
                <reportElement mode="Transparent" x="0" y="12" width="100" height="1" forecolor="#FFFFFF" uuid="99aed6f5-8941-4876-a95c-1ee23bd1dc0a">
                    <propertyExpression name="net.sf.jasperreports.export.xls.sheet.name"><![CDATA["Dados"]]></propertyExpression>
                </reportElement>
            </line>
        </band>
    </pageHeader>
    <columnHeader>
        <band height="16">
            <frame>
                <reportElement key="columnHeader.list1" positionType="Float" x="0" y="0" width="1352" height="16" uuid="46d7f64e-9ba3-4fa3-b6f4-f4cde887a658"/>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="columnHeader.column_Codigo do candidato.title1" style="TabelaCabecalho" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="104" height="16" uuid="4e458915-229a-4de2-8cdc-ca86d9721252"/>
                    <textFieldExpression><![CDATA[$P{CUSTOM_VALUES}.getValue("simpleExpression_10_")]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="columnHeader.column_Nome.title1" style="TabelaCabecalho" positionType="Float" stretchType="RelativeToTallestObject" x="104" y="0" width="104" height="16" uuid="95caf451-7a8b-41a6-a942-21cb7e3e6110"/>
                    <textFieldExpression><![CDATA[$P{CUSTOM_VALUES}.getValue("simpleExpression_12_")]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="columnHeader.column_E-mail.title1" style="TabelaCabecalho" positionType="Float" stretchType="RelativeToTallestObject" x="208" y="0" width="104" height="16" uuid="f1b3ad3f-c55d-478d-b4b5-9c73fb414477"/>
                    <textFieldExpression><![CDATA[$P{CUSTOM_VALUES}.getValue("simpleExpression_14_")]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="columnHeader.column_Idade.title1" style="TabelaCabecalho" positionType="Float" stretchType="RelativeToTallestObject" x="312" y="0" width="104" height="16" uuid="df361b4f-cad3-4770-b75c-38bfe3f1c281"/>
                    <textFieldExpression><![CDATA[$P{CUSTOM_VALUES}.getValue("simpleExpression_16_")]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="columnHeader.column_Telefone(s) Contato.title1" style="TabelaCabecalho" positionType="Float" stretchType="RelativeToTallestObject" x="416" y="0" width="104" height="16" uuid="4dc88b66-dcd6-4626-a788-7da1f70f7f6b"/>
                    <textFieldExpression><![CDATA[$P{CUSTOM_VALUES}.getValue("simpleExpression_18_")]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="columnHeader.column_Cidade e Estado.title1" style="TabelaCabecalho" positionType="Float" stretchType="RelativeToTallestObject" x="520" y="0" width="104" height="16" uuid="011ca35b-fe81-484e-aa1b-d383053452df"/>
                    <textFieldExpression><![CDATA[$P{CUSTOM_VALUES}.getValue("simpleExpression_20_")]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="columnHeader.column_Tipo de Formação 1.title1" style="TabelaCabecalho" positionType="Float" stretchType="RelativeToTallestObject" x="624" y="0" width="104" height="16" uuid="1e31895e-9fcf-4bb0-8e40-bd419c0af763"/>
                    <textFieldExpression><![CDATA[$P{CUSTOM_VALUES}.getValue("simpleExpression_22_")]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="columnHeader.column_Formação 1.title1" style="TabelaCabecalho" positionType="Float" stretchType="RelativeToTallestObject" x="728" y="0" width="104" height="16" uuid="86ed4ae1-7600-4df3-966f-401f1967e93b"/>
                    <textFieldExpression><![CDATA[$P{CUSTOM_VALUES}.getValue("simpleExpression_24_")]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="columnHeader.column_Instituição 1.title1" style="TabelaCabecalho" positionType="Float" stretchType="RelativeToTallestObject" x="832" y="0" width="104" height="16" uuid="1ce1e9dc-816a-410f-b4f0-71550c59ceeb"/>
                    <textFieldExpression><![CDATA[$P{CUSTOM_VALUES}.getValue("simpleExpression_26_")]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="columnHeader.column_Tipo de Formação 2.title1" style="TabelaCabecalho" positionType="Float" stretchType="RelativeToTallestObject" x="936" y="0" width="104" height="16" uuid="e589cd82-0758-468a-92e8-dc1a81f793ba"/>
                    <textFieldExpression><![CDATA[$P{CUSTOM_VALUES}.getValue("simpleExpression_28_")]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="columnHeader.column_Formação 2.title1" style="TabelaCabecalho" positionType="Float" stretchType="RelativeToTallestObject" x="1040" y="0" width="104" height="16" uuid="e719543b-a0e6-4f36-b265-82b0f6dbb11e"/>
                    <textFieldExpression><![CDATA[$P{CUSTOM_VALUES}.getValue("simpleExpression_30_")]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="columnHeader.column_Instituição 2.title1" style="TabelaCabecalho" positionType="Float" stretchType="RelativeToTallestObject" x="1144" y="0" width="104" height="16" uuid="d06d26bc-71a4-4444-b061-4e05bb1b7168"/>
                    <textFieldExpression><![CDATA[$P{CUSTOM_VALUES}.getValue("simpleExpression_32_")]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="columnHeader.column_Histórico profissional (2 últimas empresas).title1" style="TabelaCabecalho" positionType="Float" stretchType="RelativeToTallestObject" x="1248" y="0" width="104" height="16" uuid="0cd532cc-f4fb-47e9-aeff-cc1c61bd8a6c"/>
                    <textFieldExpression><![CDATA[$P{CUSTOM_VALUES}.getValue("simpleExpression_34_")]]></textFieldExpression>
                </textField>
            </frame>
        </band>
    </columnHeader>
    <detail>
        <band height="16">
            <frame>
                <reportElement key="detail.list1" positionType="Float" x="0" y="0" width="1352" height="16" uuid="6d7ecd54-a04a-477e-9848-3247fb8ef789"/>
                <textField isStretchWithOverflow="true" pattern="#,##0" isBlankWhenNull="true">
                    <reportElement key="detail.column_Codigo do candidato1" style="style_36_" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="104" height="16" isPrintInFirstWholeBand="true" uuid="640caec8-b919-41e2-aa57-93db114b9aec"/>
                    <textElement textAlignment="Right"/>
                    <textFieldExpression><![CDATA[$F{Codigo do candidato}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="detail.column_Nome1" style="style_36_" positionType="Float" stretchType="RelativeToTallestObject" x="104" y="0" width="104" height="16" isPrintInFirstWholeBand="true" uuid="78c8ddc7-82c5-4b8e-8ae2-a0c6be535dc7"/>
                    <textElement textAlignment="Left"/>
                    <textFieldExpression><![CDATA[$F{Nome}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="detail.column_E-mail1" style="style_36_" positionType="Float" stretchType="RelativeToTallestObject" x="208" y="0" width="104" height="16" isPrintInFirstWholeBand="true" uuid="c687dc47-b312-45d1-8f8f-af0952d2e0ad"/>
                    <textElement textAlignment="Left"/>
                    <textFieldExpression><![CDATA[$F{E-mail}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" pattern="#,##0" isBlankWhenNull="true">
                    <reportElement key="detail.column_Idade1" style="style_36_" positionType="Float" stretchType="RelativeToTallestObject" x="312" y="0" width="104" height="16" isPrintInFirstWholeBand="true" uuid="74fe0b04-c84b-4a82-96e8-1fa83acf5989"/>
                    <textElement textAlignment="Right"/>
                    <textFieldExpression><![CDATA[$F{Idade}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="detail.column_Telefone(s) Contato1" style="style_36_" positionType="Float" stretchType="RelativeToTallestObject" x="416" y="0" width="104" height="16" isPrintInFirstWholeBand="true" uuid="f25f3fbd-3d07-4865-9ba0-9196281a3536"/>
                    <textElement textAlignment="Left"/>
                    <textFieldExpression><![CDATA[$F{Telefone(s) Contato}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="detail.column_Cidade e Estado1" style="style_36_" positionType="Float" stretchType="RelativeToTallestObject" x="520" y="0" width="104" height="16" isPrintInFirstWholeBand="true" uuid="2bef953f-ea52-4750-af77-0a8bc3efc3a0"/>
                    <textElement textAlignment="Left"/>
                    <textFieldExpression><![CDATA[$F{Cidade e Estado}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="detail.column_Tipo de Formação 11" style="style_36_" positionType="Float" stretchType="RelativeToTallestObject" x="624" y="0" width="104" height="16" isPrintInFirstWholeBand="true" uuid="a614443a-b729-4037-943c-d16f3ba8d1e9"/>
                    <textElement textAlignment="Left"/>
                    <textFieldExpression><![CDATA[$F{Tipo de Formação 1}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="detail.column_Formação 11" style="style_36_" positionType="Float" stretchType="RelativeToTallestObject" x="728" y="0" width="104" height="16" isPrintInFirstWholeBand="true" uuid="ac8d1676-a360-439f-925d-262df7f356e2"/>
                    <textElement textAlignment="Left"/>
                    <textFieldExpression><![CDATA[$F{Formação 1}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="detail.column_Instituição 11" style="style_36_" positionType="Float" stretchType="RelativeToTallestObject" x="832" y="0" width="104" height="16" isPrintInFirstWholeBand="true" uuid="e35aeb7c-a96d-41d3-a1c0-1c707c890d19"/>
                    <textElement textAlignment="Left"/>
                    <textFieldExpression><![CDATA[$F{Instituição 1}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="detail.column_Tipo de Formação 21" style="style_36_" positionType="Float" stretchType="RelativeToTallestObject" x="936" y="0" width="104" height="16" isPrintInFirstWholeBand="true" uuid="e8421e2e-5aa8-4ef5-b304-f49f708cc7df"/>
                    <textElement textAlignment="Left"/>
                    <textFieldExpression><![CDATA[$F{Tipo de Formação 2}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="detail.column_Formação 21" style="style_36_" positionType="Float" stretchType="RelativeToTallestObject" x="1040" y="0" width="104" height="16" isPrintInFirstWholeBand="true" uuid="c43405f4-08ef-484a-aa7b-de76c850bd48"/>
                    <textElement textAlignment="Left"/>
                    <textFieldExpression><![CDATA[$F{Formação 2}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="detail.column_Instituição 21" style="style_36_" positionType="Float" stretchType="RelativeToTallestObject" x="1144" y="0" width="104" height="16" isPrintInFirstWholeBand="true" uuid="3f1903a0-30a2-430b-bd57-7c8ce1211a82"/>
                    <textElement textAlignment="Left"/>
                    <textFieldExpression><![CDATA[$F{Instituição 2}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement key="detail.column_Histórico profissional (2 últimas empresas)1" style="style_36_" positionType="Float" stretchType="RelativeToTallestObject" x="1248" y="0" width="104" height="16" isPrintInFirstWholeBand="true" uuid="f07d5d11-9422-4c35-b8f5-3904982ca456"/>
                    <textElement textAlignment="Left"/>
                    <textFieldExpression><![CDATA[$F{Histórico profissional (2 últimas empresas)}]]></textFieldExpression>
                </textField>
            </frame>
        </band>
    </detail>
    <pageFooter>
        <band height="38" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="46" splitType="Stretch">
            <property name="local_mesure_unitheight" value="pixel"/>
            <textField pattern="">
                <reportElement x="0" y="34" width="560" height="12" uuid="4ca54330-fb17-4ef6-8d18-3ceace2083b9"/>
                <textElement textAlignment="Left"/>
                <textFieldExpression><![CDATA["Relatório gerado por VAGAS Tecnologia de Software em " + new SimpleDateFormat("dd/MM/yy HH:mm:ss").format(new java.util.Date())]]></textFieldExpression>
            </textField>
        </band>
    </summary>
</jasperReport>

解决方法:

您将保存未填充的报表的编译版本,而不是JasperPrint对象的JasperDesign对象

您应该使用report.toJasperPrint()

JRSaver.saveObject(report.toJasperPrint(),  "fullPath/yourReport.jrprint");

要重新加载已填写的报告,请使用:

JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(new java.io.FileInputStream("fullPath/yourReport.jrprint"));

并使用JasperExportManager或导出类示例JRXlsExporter之一进行导出

标签:export-to-excel,jasper-reports,dynamic-reports,java
来源: https://codeday.me/bug/20191118/2026613.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有