aBanhidy
aBanhidy

Reputation: 291

How can I set table colspan?

My question is that how I can set colspan value for a table footer column in iReport, in jrxml file.

I have to use iReport to create easily my PDF design. I send fields and parameters values from PHP via Tomcat. I don't use Java for create a dynamic jasper report.

That means I have to resolve my problem from jrxml.

Is it possible to make it?

Upvotes: 2

Views: 16532

Answers (2)

Thomas
Thomas

Reputation: 1149

You can't do a colspan as such but you can group the table columns in iReport (select more than 1 column in the table footer). Then remove the cells of the individual columns in the footer and add a cell for the "Group Header" in the footer. All pure iReport/JRXML.

iReport Inspector for grouped table footer

Upvotes: 6

aBanhidy
aBanhidy

Reputation: 291

Detail part of xml:

    <detail>
    <band height="43" splitType="Stretch">
        <textField>
            <reportElement x="0" y="0" width="344" height="20"/>
            <box>
                <bottomPen lineWidth="0.5"/>
            </box>
            <textElement verticalAlignment="Middle">
                <font isBold="true"/>
            </textElement>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{data_title}]]></textFieldExpression>
        </textField>
        <componentElement>
            <reportElement key="table" x="0" y="20" width="802" height="20"/>
            <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="details">
                    <datasetParameter name="credit">
                        <datasetParameterExpression><![CDATA[$F{credit}]]></datasetParameterExpression>
                    </datasetParameter>
                    <datasetParameter name="debit_gross_sum">
                        <datasetParameterExpression><![CDATA[$F{debit_gross_sum}]]></datasetParameterExpression>
                    </datasetParameter>
                    <datasetParameter name="debit_net_sum">
                        <datasetParameterExpression><![CDATA[$F{debit_net_sum}]]></datasetParameterExpression>
                    </datasetParameter>
                    <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRMapCollectionDataSource($F{details})]]></dataSourceExpression>
                </datasetRun>
                <jr:column width="12">
                    <jr:tableFooter height="15" rowSpan="1"/>
                    <jr:detailCell height="20" rowSpan="1"/>
                </jr:column>
                <jr:column width="48">
                    <jr:tableFooter height="15" rowSpan="1"/>
                    <jr:detailCell height="20" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="48" height="20"/>
                            <textElement>
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[$F{time}]]></textFieldExpression>
                        </textField>
                    </jr:detailCell>
                </jr:column>
                <jr:column width="106">
                    <jr:tableFooter height="15" rowSpan="1"/>
                    <jr:detailCell height="20" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="106" height="20"/>
                            <textElement>
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[$F{description}]]></textFieldExpression>
                        </textField>
                    </jr:detailCell>
                </jr:column>
                <jr:column width="130">
                    <jr:tableFooter height="15" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="130" height="15"/>
                            <box>
                                <bottomPen lineWidth="0.5"/>
                            </box>
                            <textElement>
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[""]]></textFieldExpression>
                        </textField>
                    </jr:tableFooter>
                    <jr:detailCell height="20" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="130" height="20"/>
                            <textElement>
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[$F{guest_name}]]></textFieldExpression>
                        </textField>
                    </jr:detailCell>
                </jr:column>
                <jr:column width="48">
                    <jr:tableFooter height="15" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="48" height="15"/>
                            <box>
                                <bottomPen lineWidth="0.5"/>
                            </box>
                            <textElement>
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[""]]></textFieldExpression>
                        </textField>
                    </jr:tableFooter>
                    <jr:detailCell height="20" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="48" height="20"/>
                            <textElement>
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[$F{room}]]></textFieldExpression>
                        </textField>
                    </jr:detailCell>
                </jr:column>
                <jr:column width="79">
                    <jr:tableFooter height="15" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="79" height="15"/>
                            <box>
                                <bottomPen lineWidth="0.5"/>
                            </box>
                            <textElement>
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[""]]></textFieldExpression>
                        </textField>
                    </jr:tableFooter>
                    <jr:detailCell height="20" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="79" height="20"/>
                            <textElement>
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[$F{cachier_user}]]></textFieldExpression>
                        </textField>
                    </jr:detailCell>
                </jr:column>
                <jr:column width="77">
                    <jr:tableFooter height="15" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="77" height="15"/>
                            <box>
                                <bottomPen lineWidth="0.5"/>
                            </box>
                            <textElement>
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[""]]></textFieldExpression>
                        </textField>
                    </jr:tableFooter>
                    <jr:detailCell height="20" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="77" height="20"/>
                            <textElement>
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[$F{source_room}]]></textFieldExpression>
                        </textField>
                    </jr:detailCell>
                </jr:column>
                <jr:column width="126">
                    <jr:tableFooter height="15" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="126" height="15"/>
                            <box>
                                <bottomPen lineWidth="0.5"/>
                            </box>
                            <textElement>
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[""]]></textFieldExpression>
                        </textField>
                    </jr:tableFooter>
                    <jr:detailCell height="20" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="126" height="20"/>
                            <textElement>
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[$F{source_guest_name}]]></textFieldExpression>
                        </textField>
                    </jr:detailCell>
                </jr:column>
                <jr:column width="70">
                    <jr:tableFooter height="15" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="70" height="15"/>
                            <box rightPadding="0">
                                <topPen lineWidth="0.5"/>
                                <bottomPen lineWidth="0.5"/>
                            </box>
                            <textElement textAlignment="Right">
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[$P{debit_gross_sum}]]></textFieldExpression>
                        </textField>
                    </jr:tableFooter>
                    <jr:detailCell height="20" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="70" height="20"/>
                            <textElement textAlignment="Right">
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[$F{debit_gross}]]></textFieldExpression>
                        </textField>
                    </jr:detailCell>
                </jr:column>
                <jr:column width="70">
                    <jr:tableFooter height="15" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="70" height="15"/>
                            <box rightPadding="0">
                                <topPen lineWidth="0.5"/>
                                <bottomPen lineWidth="0.5"/>
                            </box>
                            <textElement textAlignment="Right">
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[$P{debit_net_sum}]]></textFieldExpression>
                        </textField>
                    </jr:tableFooter>
                    <jr:detailCell height="20" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="70" height="20"/>
                            <textElement textAlignment="Right">
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[$F{debit_net}]]></textFieldExpression>
                        </textField>
                    </jr:detailCell>
                </jr:column>
                <jr:column width="37">
                    <jr:tableFooter height="15" rowSpan="1">
                        <textField isBlankWhenNull="true">
                            <reportElement x="0" y="0" width="37" height="15"/>
                            <box>
                                <topPen lineWidth="0.5"/>
                                <bottomPen lineWidth="0.5"/>
                            </box>
                            <textElement textAlignment="Right" verticalAlignment="Top">
                                <font pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression class="java.lang.String"><![CDATA[$P{credit}]]></textFieldExpression>
                        </textField>
                    </jr:tableFooter>
                    <jr:detailCell height="20" rowSpan="1"/>
                </jr:column>
            </jr:table>
        </componentElement>
    </band>
</detail>

I would like to close up from tableFotter 3. cell 4 cells.

Thank you Alex K!

Upvotes: 0

Related Questions