Indra.Polak Posted September 24, 2018 Share Posted September 24, 2018 Hi I am trying to create a table but its not showing in the output.My jrxml looks like <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 --><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="UnitDelivery" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="15" bottomMargin="5" uuid="eafaed83-593d-4442-be54-453343e6082f"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> <style name="defaultStyle" isDefault="true" fontName="UbuntuEmbedded" fontSize="9" pdfEncoding="Identity-H" isPdfEmbedded="true"/> <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <subDataset name="Dataset1" uuid="1a616eb6-13bb-43c4-ac02-ccd28a679f6f"> <parameter name="ds_ch_0" class="java.lang.String"/> <queryString> <![CDATA[]]> </queryString> <field name="COLUMN_0" class="java.lang.String"/> <field name="COLUMN_1" class="java.lang.String"/> <field name="COLUMN_2" class="java.lang.String"/> <field name="COLUMN_3" class="java.lang.String"/> <field name="COLUMN_4" class="java.lang.String"/> </subDataset> <parameter name="footer_1" class="java.lang.String"> <parameterDescription><![CDATA[adres]]></parameterDescription> </parameter> <parameter name="footer_2" class="java.lang.String"> <parameterDescription><![CDATA[street]]></parameterDescription> </parameter> <parameter name="footer_3" class="java.lang.String"> <parameterDescription><![CDATA[Postal Code]]></parameterDescription> </parameter> <parameter name="footer_4" class="java.lang.String"> <parameterDescription><![CDATA[Country]]></parameterDescription> </parameter> <parameter name="footer_5" class="java.lang.String"> <parameterDescription><![CDATA[www]]></parameterDescription> </parameter> <parameter name="ch_0" class="java.lang.String"> <parameterDescription><![CDATA[date]]></parameterDescription> </parameter> <parameter name="ch_1" class="java.lang.String"> <parameterDescription><![CDATA[interval]]></parameterDescription> </parameter> <parameter name="ch_2" class="java.lang.String"> <parameterDescription><![CDATA[mileage]]></parameterDescription> </parameter> <parameter name="ch_3" class="java.lang.String"> <parameterDescription><![CDATA[months in service]]></parameterDescription> </parameter> <parameter name="ch_4" class="java.lang.String"> <parameterDescription><![CDATA[dealer]]></parameterDescription> </parameter> <parameter name="IndraDatasource" class="net.sf.jasperreports.engine.data.JRTableModelDataSource" /> <background> <band splitType="Stretch"/> </background> <pageHeader> <band height="405"> <image> <reportElement x="110" y="30" width="340" height="60" uuid="312bed8a-7d46-4281-b3b2-6686a46d1293"/> <imageExpression><![CDATA["/contract_templates/yamaha-logo.png"]]></imageExpression> </image> <textField> <reportElement x="-20" y="140" width="595" height="30" uuid="ebd903a8-b3f6-4788-b7f6-0a8b55ff5ae9"/> <textElement textAlignment="Center" markup="styled"> <font size="16" isBold="true"/> </textElement> <textFieldExpression><![CDATA[$R{pdf.label.digital.service.record}]]></textFieldExpression> </textField> <textField> <reportElement x="20" y="190" width="170" height="30" uuid="1559d111-d797-4300-87b2-9166265b228a"/> <textElement markup="html"> <font size="12" isBold="true"/> </textElement> <textFieldExpression><![CDATA[$R{label.unitDetails}]]></textFieldExpression> </textField> <textField> <reportElement x="30" y="240" width="100" height="15" uuid="bbee96b9-37c8-4c1a-bb33-cc5b22f292e9"/> <textFieldExpression><![CDATA[$R{label.unitID}]]></textFieldExpression> </textField> <textField> <reportElement x="30" y="260" width="100" height="15" uuid="36a475ab-f904-43b7-949b-ebdffc859b57"/> <textFieldExpression><![CDATA[$R{label.modelName}]]></textFieldExpression> </textField> <textField> <reportElement x="180" y="240" width="100" height="15" uuid="692bad98-01f4-4185-8588-e00071506443"/> <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression> </textField> <textField> <reportElement x="180" y="260" width="100" height="15" uuid="279c1da5-5238-40db-8ecf-5302130f2585"/> <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression> </textField> <textField> <reportElement x="30" y="300" width="100" height="15" uuid="50a455d0-8be4-4e9c-a2d7-501965bfa506"/> <textFieldExpression><![CDATA[$R{label.warrantyEndDate}]]></textFieldExpression> </textField> <textField> <reportElement x="30" y="320" width="100" height="15" uuid="490afb16-483c-4c8a-9929-dfa4f60733b0"/> <textFieldExpression><![CDATA[$R{label.extendedWarrantyEndDate}]]></textFieldExpression> </textField> <textField> <reportElement x="180" y="280" width="100" height="15" uuid="e3f354bd-0b94-468b-b666-3a5604c46a9e"/> <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression> </textField> <textField> <reportElement x="180" y="300" width="100" height="15" uuid="94cd8595-d4e4-4aa6-8400-744429ed272a"/> <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression> </textField> <textField> <reportElement x="180" y="320" width="100" height="15" uuid="2d348ff5-51ad-4585-a232-3bc2b5fbe7c8"/> <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression> </textField> <textField> <reportElement x="30" y="280" width="100" height="15" uuid="daa80cc1-314d-4d0b-8c44-b99835ab8d0f"/> <textFieldExpression><![CDATA[$R{label.warrantyStartDate}]]></textFieldExpression> </textField> </band> </pageHeader> <columnHeader> <band height="50"> <textField> <reportElement x="10" y="20" width="100" height="24" uuid="d844cada-1aa4-4208-9fc1-dcdf62a72235"/> <textFieldExpression><![CDATA[$P{ch_0}]]></textFieldExpression> </textField> <textField> <reportElement x="130" y="20" width="75" height="24" uuid="14399970-e399-41e0-b6f9-1218079fd56c"/> <textFieldExpression><![CDATA[$P{ch_1}]]></textFieldExpression> </textField> <textField> <reportElement x="230" y="20" width="50" height="24" uuid="b5b0fe03-9b8f-48c6-ba51-c218427028f6"/> <textFieldExpression><![CDATA[$P{ch_2}]]></textFieldExpression> </textField> <textField> <reportElement x="300" y="20" width="60" height="24" uuid="c3094477-bb5e-4d5c-a440-8d7c7f2a1d3e"/> <textFieldExpression><![CDATA[$P{ch_3}]]></textFieldExpression> </textField> <textField> <reportElement x="380" y="20" width="160" height="24" uuid="c3094477-bb5e-4d5c-a440-8d7c7f2a1d3f"/> <textFieldExpression><![CDATA[$P{ch_4}]]></textFieldExpression> </textField> </band> </columnHeader> <detail> <band height="260"> <componentElement> <reportElement x="10" y="60" width="524" height="160" uuid="6cd16b6d-6779-412b-b3ee-2edcc1c94de0"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/> <property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/> <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/> <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/> </reportElement> <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"> <datasetRun subDataset="Dataset1" uuid="64bea3cc-476a-4a8d-b2a4-17aefef755cc"> <datasetParameter name="ds_ch_0"> <datasetParameterExpression><![CDATA[$P{ch_0}]]></datasetParameterExpression> </datasetParameter> <dataSourceExpression><![CDATA[$P{IndraDatasource}]]></dataSourceExpression> </datasetRun> <jr:column width="150" uuid="40de5a91-e20f-446a-9651-c0fb84181d5b"> <jr:tableHeader style="Table_TH" height="30"> <textField> <reportElement x="0" y="0" width="130" height="30" uuid="f60d1675-6fb6-4569-93ca-de32b3a8e861"/> <textFieldExpression><![CDATA[$P{ds_ch_0}]]></textFieldExpression> </textField> </jr:tableHeader> <jr:tableFooter style="Table_TH" height="30"/> <jr:columnHeader style="Table_CH" height="30"/> <jr:columnFooter style="Table_CH" height="30"/> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="130" height="25" uuid="341e7faf-9680-4941-a9a4-ac78b8f4aae0"/> <textFieldExpression><![CDATA[$F{COLUMN_0}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="75" uuid="40de5a91-e20f-446a-9651-c0fb84181d5b"> <jr:tableHeader style="Table_TH" height="30"/> <jr:tableFooter style="Table_TH" height="30"/> <jr:columnHeader style="Table_CH" height="30"/> <jr:columnFooter style="Table_CH" height="30"/> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="75" height="25" uuid="14399970-e399-41e0-b6f9-1218079fd56c"/> <textFieldExpression><![CDATA[$F{COLUMN_1}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="75" uuid="40de5a91-e20f-446a-9651-c0fb84181d5b"> <jr:tableHeader style="Table_TH" height="30"/> <jr:tableFooter style="Table_TH" height="30"/> <jr:columnHeader style="Table_CH" height="30"/> <jr:columnFooter style="Table_CH" height="30"/> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="75" height="25" uuid="14399970-e399-41e0-b6f9-1218079fd56c"/> <textFieldExpression><![CDATA[$F{COLUMN_2}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="75" uuid="40de5a91-e20f-446a-9651-c0fb84181d5b"> <jr:tableHeader style="Table_TH" height="30"/> <jr:tableFooter style="Table_TH" height="30"/> <jr:columnHeader style="Table_CH" height="30"/> <jr:columnFooter style="Table_CH" height="30"/> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="75" height="25" uuid="14399970-e399-41e0-b6f9-1218079fd56c"/> <textFieldExpression><![CDATA[$F{COLUMN_3}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="75" uuid="40de5a91-e20f-446a-9651-c0fb84181d5b"> <jr:tableHeader style="Table_TH" height="30"/> <jr:tableFooter style="Table_TH" height="30"/> <jr:columnHeader style="Table_CH" height="30"/> <jr:columnFooter style="Table_CH" height="30"/> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="75" height="25" uuid="14399970-e399-41e0-b6f9-1218079fd56c"/> <textFieldExpression><![CDATA[$F{COLUMN_4}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> </jr:table> </componentElement> </band> </detail> <pageFooter> <band height="78"> <image> <reportElement x="10" y="14" width="112" height="50" uuid="75bb4e39-0e3b-45d9-9ebe-f5a2693b23e9"/> <imageExpression><![CDATA["/contract_templates/yamalube.jpg"]]></imageExpression> </image> <textField> <reportElement x="200" y="3" width="160" height="15" uuid="2b3a12c2-733b-492e-b6dd-b5cec3b96ee0"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$P{footer_1}]]></textFieldExpression> </textField> <textField> <reportElement x="200" y="18" width="160" height="15" uuid="f7300b6d-b123-418c-bd61-1ca5fc80d64b"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$P{footer_2}]]></textFieldExpression> </textField> <textField> <reportElement x="200" y="33" width="160" height="15" uuid="3a79f09b-83ad-4a15-b0b3-600cbacb9df0"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$P{footer_3}]]></textFieldExpression> </textField> <textField> <reportElement x="200" y="48" width="160" height="15" uuid="1a697cc6-35ba-483e-bbb5-7bf7bc114e73"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$P{footer_4}]]></textFieldExpression> </textField> <textField> <reportElement x="200" y="63" width="160" height="15" uuid="ff6e7d04-9190-4a95-b201-40459b094563"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$P{footer_5}]]></textFieldExpression> </textField> <image> <reportElement x="400" y="11" width="134" height="50" uuid="8dccc4c3-bb75-4094-8258-59ce88a0ffb5"/> <imageExpression><![CDATA["/contract_templates/Yamaha-Accessories_CMYK.jpg"]]></imageExpression> </image> </band> </pageFooter></jasperReport> calling java code isInputStream stream = getClass().getResourceAsStream("/contract_templates/SVR.jrxml");JasperReport jasperReport = JasperCompileManager.compileReport(stream);DefaultTableModel tableModel = createTableModel(locale, serviceRecordDTOs);JRDataSource jrDataSource = new JRTableModelDataSource(tableModel);JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, jrDataSource);//try { byte[] pdf = JasperExportManager.exportReportToPdf(jasperPrint); return pdf;[/code]In the params I have the resource bundle (that is working fine) and all the parameters like footer_1...and ch_0,ch_1,...The output shows everything except the table data. What am I doing wrong?Thanks, Indra Link to comment Share on other sites More sharing options...
reportdev Posted September 24, 2018 Share Posted September 24, 2018 I dont see IndraDatasource being populated in your java code.If the resource bundle already has data, then there is an issue with class type.Report datasource are usually of type JRBeanCollectionDataSource Link to comment Share on other sites More sharing options...
Indra.Polak Posted September 25, 2018 Author Share Posted September 25, 2018 Hi Reportdev thx for the quick response. I populated a JRDataSource with the data in the java code, but I think I understand what you mean. I'll also add the data model as a separate parameter and see if that works. Link to comment Share on other sites More sharing options...
Indra.Polak Posted September 25, 2018 Author Share Posted September 25, 2018 I got it working using the JRBeanCollectionDataSource as a parameter and a JREmptyDataSource.Thx for the tip! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now