jasper-reportstable-footer

How to set table column footer to the bottom of the detail band?


I'm using table in jasperreport and I need to add table column footer to the bottom just before "group footer" band like

here

But currently it generates table like here

this

as you can see a lot of spaces between the table (which in detail band) and group footer band..

<detail>
    <band height="80">
        <componentElement>
            <reportElement key="table1" style="tableStyle" x="1" y="0" width="552" height="80" isPrintWhenDetailOverflows="true" uuid="9a24d27b-9228-4f23-8c02-628268479882">
                <printWhenExpression><![CDATA[$V{REPORT_COUNT} == 1]]></printWhenExpression>
            </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" whenNoDataType="AllSectionsNoDetail">
                <datasetRun subDataset="TableDataset" uuid="aad66998-86ba-485c-b8f4-3f2f6eda4796">
                    <dataSourceExpression><![CDATA[$P{datasourceItems}]]></dataSourceExpression>
                </datasetRun>
                <jr:column width="25" uuid="eb2f74b3-8006-4762-a52e-838f5e08a86f">
                    <jr:columnHeader height="40" rowSpan="2">
                        <staticText>
                            <reportElement style="tableProduct_CH" x="0" y="0" width="25" height="40" uuid="6ce8147d-c282-467a-b348-0d5cf3def735"/>
                            <textElement textAlignment="Center" verticalAlignment="Middle"/>
                            <text><![CDATA[No]]></text>
                        </staticText>
                    </jr:columnHeader>
                    <jr:columnFooter style="tableProductFooterNoLine" height="20" rowSpan="1"/>
                    <jr:detailCell height="20" rowSpan="1">
                        <textField isStretchWithOverflow="true">
                            <reportElement style="tableProduct_TD" x="0" y="0" width="25" height="20" uuid="fc581740-46a3-4602-b769-18beca53d355"/>
                            <textElement textAlignment="Center"/>
                            <textFieldExpression><![CDATA[$F{no}]]></textFieldExpression>
                        </textField>
                    </jr:detailCell>
                </jr:column> ...
            </jr:table>
        </componentElement>
    </band>
</detail>

Solution

  • AFIK: This is not possible in jasper reports version <=6.7 (current version at date of answer) using the jr:table component.

    You could draw the lines in the background band and then add the footer for example in a groupFooter band, but I would instead suggest that you create a subreport to avoid problems with page break.

    The subreport will mimic the table using the standard detail and columnFooter band, again you will be adding the vertical lines in the background band.

    How the columnFooter will behave is define by the attribute isFloatColumnFooter hence in your case false