2016-08-29 3 views
3

Я создаю отчет Jasper с помощью библиотеки Dynamic Reports. Я пытаюсь скомпилировать динамические отчеты, чтобы использовать скомпилированную версию позже. Но скомпилированная версия моего доклада не отражает изменения, которые сделаны динамические отчетыПочему скомпилированные динамические отчеты (.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())

Но, в другой точке приложения, я проверяю, существует ли скомпилированный шаблон. Если он существует, я использую скомпилированный шаблон для создания отчета.

Однако, когда я пытаюсь сгенерировать шаблон с использованием скомпилированной версии, он возвращает пустое.

Он генерирует без столбцов записи, которые я добавил динамически в приведенном выше коде.

Обновление статуса
31/08/2016
Моя ситуация: У меня есть процедура, которая содержит динамический выход (в зависимости от параметра, который вы получаете). Следовательно, когда процедура получает аргумент @Cod = 1, например, она будет иметь конкретный вывод SQL. Я хочу, чтобы при первом запуске динамических отчетов генерировался скомпилированный отчет (.jasper) на основе вывода процедуры. И в последующие моменты я могу повторно использовать скомпилированный отчет (.jasper), чтобы генерировать новые отчеты только с его использованием.

Я решил часть проблемы. Когда он запускается во второй раз, в шаблоне jrxml не было SQL. Итак, я вставил следующий код в этом шаблоне jrxml:


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

и я вставить следующий код в моей программе (при использовании .jasper генерируемый в DynamicReports):

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> 

+0

Я ответил на эти вопросы, но думаю, вам стоит рассмотреть, чтобы просмотреть ваши старые вопросы, чтобы узнать, есть ли ответы на них, которые должны быть приняты, см. [Tour] (http://stackoverflow.com/tour), чтобы узнать, что [принято] (http://stackoverflow.com/help/accepted-answer). –

+0

Хорошо. Мне удалось добиться определенного прогресса, но я не могу решить эту проблему. Вы можете увидеть мой ответ. Спасибо! – diegoqueres

ответ

2

Вы спасаете скомпилированную версию доклада, которая не заполнена, то JasperDesign объект а не JasperPrint

Вы должны использовать report.toJasperPrint()

Примера

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

Для перезарядки ваше заполненное использование отчета:

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

И экспорта это использовать JasperExportManager или один из класса экспорта пример JRXlsExporter

1

FIXED PROBLEM Я нахожу решение проблемы. Проблема заключалась в зависимости от DYNAMIC REPORTS и CUSTOM_VALUES. Когда я использую скомпилированный отчет, он не нашел эти значения.

Итак, мне нужно изменить каждое место, где есть такая зависимость, и заставить отчет использовать собственные выражения отчетов Jasper.

я мог понять, с объяснениями Рикарду в этой теме: http://www.dynamicreports.org/forum/viewtopic.php?f=1&t=579&p=1983&hilit=custom_values&sid=8757448603905e175044b8637780d608#p1983

Таким образом, я использовать этот объект для создания Джаспер собственные выражения: net.sf.dynamicreports.report.builder.DynamicReports.exp. Я исправляю .setTitle для записи в синтаксисе jasper: column.setTitle (exp.jasperSyntaxText («Некоторое название»));

Крепление этот метод:

public List<TextColumnBuilder> getDRColumnsFromRecordset(ResultSet rs) throws SQLException { 
     ResultSetMetaData rsmd = rs.getMetaData(); 
     List<TextColumnBuilder> lsColumns = new ArrayList<>(); 
     TextColumnBuilder column = null; 

     for (int i = 1; i <= rsmd.getColumnCount(); i++) { 
      switch (rsmd.getColumnType(i)) { 
       case Types.VARCHAR: 
       case Types.NVARCHAR: 
        column = col.column(rsmd.getColumnName(i), rsmd.getColumnName(i), type.stringType()); 
        break; 

       case Types.INTEGER: 
        column = col.column(rsmd.getColumnName(i), rsmd.getColumnName(i), type.integerType()); 
        break; 

       default: 
        column = col.column(rsmd.getColumnName(i), rsmd.getColumnName(i), type.stringType()); 
        break; 

      } 
      column.setMinColumns(10); 
      column.addProperty(JasperProperty.PRINT_KEEP_FULL_TEXT, exp.jasperSyntax("\"true\"")); 
      column.addProperty(JasperProperty.EXPORT_XLS_WRAP_TEXT, exp.jasperSyntax("\"true\"")); 
      column.setTitle(exp.jasperSyntaxText(rsmd.getColumnName(i))); 

      lsColumns.add(column); 

     } 

     return lsColumns; 

    } 

Когда я использовать col.column ("Column Name", "имя столбца", type.stringType()); Я получаю имя столбца (.jasper): $ P {CUSTOM_VALUES} .getValue ("simpleExpression_10_") Так как заголовок столбца был пустым. Во второй раз у jasper нет CUSTOM_VALUES для заполнения ...

Когда я использую col.setTitle (exp.jasperSyntaxText («Название столбца»)); Я получаю название колонки (.jasper): «Название столбца»

Спасибо Петтеру за внимание! :-)