Jump to content
We've recently updated our Privacy Statement, available here ×

How to remove the table header for table component in all the pages except first page ?


sridhar964
Go to solution Solved by jan.stefany,

Recommended Posts

 

When am export my jrml to csv and pdf, am getting header repeatedly i want to avoid this ...please tell me solution.

 

Thanks in advance

 

This is my JRML

 

<?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="Finance Report" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <style name="table">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="FinanceDataSet">
        <queryString>
            <![CDATA[]]>
        </queryString>
        <field name="additionName" class="java.lang.String">
            <fieldDescription><![CDATA[additionName]]></fieldDescription>
        </field>
        <field name="cost" class="java.lang.String">
            <fieldDescription><![CDATA[cost]]></fieldDescription>
        </field>
        <field name="projectNumber" class="java.lang.String">
            <fieldDescription><![CDATA[projectNumber]]></fieldDescription>
        </field>
        <field name="projectType" class="java.lang.String">
            <fieldDescription><![CDATA[projectType]]></fieldDescription>
        </field>
        <field name="sidNumber" class="java.lang.String">
            <fieldDescription><![CDATA[sidNumber]]></fieldDescription>
        </field>
        <field name="softCost" class="java.lang.String">
            <fieldDescription><![CDATA[softCost]]></fieldDescription>
        </field>
        <field name="yearContrbToAssests" class="java.lang.String">
            <fieldDescription><![CDATA[yearContrbToAssests]]></fieldDescription>
        </field>
    </subDataset>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="68" splitType="Stretch">
            <staticText>
                <reportElement x="305" y="30" width="183" height="35"/>
                <textElement textAlignment="Center">
                    <font size="24" isBold="true"/>
                </textElement>
                <text><![CDATA[Finance Report]]></text>
            </staticText>
        </band>
    </title>
    <pageHeader>
        <band height="26" splitType="Stretch"/>
    </pageHeader>
    <detail>
        <band height="125" splitType="Stretch">
            <componentElement>
                <reportElement key="table" style="table" x="60" y="0" width="267" height="85"/>
                <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="FinanceDataSet">
                        <dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
                    </datasetRun>
                    <jr:column width="90">
                        <jr:tableHeader style="table_TH" height="1" rowSpan="1"/>
                        <jr:columnHeader style="table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement key="col_header" x="0" y="0" width="90" height="30"/>
                                <textElement verticalAlignment="Middle"/>
                                <text><![CDATA[Project Number]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="table_TD" height="21" rowSpan="1">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="21"/>
                                <textElement/>
                                <textFieldExpression><![CDATA[$F{projectNumber}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="90">
                        <jr:tableHeader style="table_TH" height="1" rowSpan="1"/>
                        <jr:columnHeader style="table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement key="col_header" x="0" y="0" width="90" height="30"/>
                                <textElement verticalAlignment="Middle"/>
                                <text><![CDATA[Project Type]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="table_TD" height="21" rowSpan="1">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="20"/>
                                <textElement/>
                                <textFieldExpression><![CDATA[$F{projectType}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="90">
                        <jr:tableHeader style="table_TH" height="1" rowSpan="1"/>
                        <jr:columnHeader style="table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement key="col_header" x="0" y="0" width="90" height="30"/>
                                <textElement verticalAlignment="Middle"/>
                                <text><![CDATA[Cost]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="table_TD" height="21" rowSpan="1">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="20"/>
                                <textElement/>
                                <textFieldExpression><![CDATA[$F{cost}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="90">
                        <jr:tableHeader style="table_TH" height="1" rowSpan="1"/>
                        <jr:columnHeader style="table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement key="col_header" x="0" y="0" width="90" height="30"/>
                                <textElement verticalAlignment="Middle"/>
                                <text><![CDATA[soft Cost]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="table_TD" height="21" rowSpan="1">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="20"/>
                                <textElement/>
                                <textFieldExpression><![CDATA[$F{softCost}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="90">
                        <jr:tableHeader style="table_TH" height="1" rowSpan="1"/>
                        <jr:columnHeader style="table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement key="col_header" x="0" y="0" width="90" height="30"/>
                                <textElement verticalAlignment="Middle"/>
                                <text><![CDATA[sid Number]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="table_TD" height="21" rowSpan="1">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="20"/>
                                <textElement/>
                                <textFieldExpression><![CDATA[$F{sidNumber}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="143">
                        <jr:tableHeader style="table_TH" height="1" rowSpan="1"/>
                        <jr:columnHeader style="table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement key="col_header" x="0" y="0" width="143" height="30"/>
                                <textElement verticalAlignment="Middle"/>
                                <text><![CDATA[Addition Name]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="table_TD" height="21" rowSpan="1">
                            <textField>
                                <reportElement x="0" y="0" width="143" height="20"/>
                                <textElement/>
                                <textFieldExpression><![CDATA[$F{additionName}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="113">
                        <jr:tableHeader style="table_TH" height="1" rowSpan="1"/>
                        <jr:columnHeader style="table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement key="col_header" x="0" y="0" width="110" height="30"/>
                                <textElement verticalAlignment="Middle"/>
                                <text><![CDATA[YearContrbToAssests]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="table_TD" height="21" rowSpan="1">
                            <textField>
                                <reportElement x="0" y="0" width="113" height="21"/>
                                <textElement/>
                                <textFieldExpression><![CDATA[$F{yearContrbToAssests}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </detail>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>
 

 

 

and controller is

for CSV export :

 outputStream = response.getOutputStream();
            jasperReport = (JasperReport) JRLoader.loadObject(sourceFile);
            jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(),jrDataSource);
            jasperPrint.getPropertiesMap().setProperty("net.sf.jasperreports.export.csv.exclude.origin.band.pageFooter", "pageFooter");
            jasperPrint.getPropertiesMap().setProperty("net.sf.jasperreports.export.csv.exclude.origin.band.title", "title");
            JRCsvExporter exporter = new JRCsvExporter();
            exporter.setParameter(JRCsvExporterParameter.JASPER_PRINT, jasperPrint);
            exporter.setParameter(JRCsvExporterParameter.OUTPUT_STREAM, outputStream);
            exporter.exportReport();

 

for Pdf export :

 

 

 sourceFile = new File(request.getSession().getServletContext().getRealPath("WEB-INF/classes/Finance Report.jasper"));
                response.setHeader("Content-Disposition", "attachment;filename=FinanceReport.pdf");
                financeReportBeanList = (List<FinanceReportBean>) request.getSession().getAttribute("financeReportList");
                financeReportBeanList.get(0).setCurrentDate(DateUtil.getCurrentDate());
                jrDataSource = new JRBeanCollectionDataSource(financeReportBeanList);

 

 

    JasperReport jasperReport=null;
            JasperPrint jasperPrint=null;
            OutputStream outputStream=null;
            outputStream = response.getOutputStream();
            jasperReport = (JasperReport) JRLoader.loadObject(sourceFile);
            jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(),jrDataSource);
            JRPdfExporter exporter = new JRPdfExporter();
            exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
            exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
            JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream);
            exporter.exportReport();

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...