我正在使用动态报告库创建一个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>
我在程序中插入以下代码(当使用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);
现在,报告会显示查询结果(如动态报告中所示)。 现在,问题是另一个问题:它不显示列标题。仅显示记录。 当我通过动态报告生成时,显示两者。使用已编译的jasper生成时,仅显示记录。
我的结果现在: 这是动态报告中的报告(未编译):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 :(得分: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 :(得分:1)
FIXED PROBLEM I find the solution for the problem. The problem was the dependence of DYNAMIC REPORTS and CUSTOM_VALUES. When i use the compiled report, it did not find these values.
So, I need modify every place where have this kind of dependence and make the report uses native expressions of Jasper Reports.
I could understand with the explanations of ricardo in this topic: http://www.dynamicreports.org/forum/viewtopic.php?f=1&t=579&p=1983&hilit=custom_values&sid=8757448603905e175044b8637780d608#p1983
So, i use this object to generate Jasper native expressions: net.sf.dynamicreports.report.builder.DynamicReports.exp. I fix the .setTitle to write in jasper syntax: column.setTitle(exp.jasperSyntaxText("Some title"));
Fixing this method:
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;
}
When i use col.column("Column name", "Column name", type.stringType()); I get in column name ( .jasper ): $P{CUSTOM_VALUES}.getValue("simpleExpression_10_") Because that, column header was blank. In the second time, jasper doesn't have CUSTOM_VALUES to fill...
When i use col.setTitle(exp.jasperSyntaxText("Column name")); I get in column name ( .jasper ): "Column name"
Thanks Petter for your attention! :-)