Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw a line for end of the page?

I am working on Jasper Reports. In my reports, I want to have the border style like below for my data

 ______ ______ ______ ______
|__H1__|__H2__|__H3__|__H4__|  
|      |      |      |      |
|      |      |      |      | 
|      |      |      |      |
|      |      |      |      | 
|______|______|______|______|

----------Page Footer--------

I would like to get the bottom border for the last line of every page. What I am currently getting is something like

 ______ ______ ______ ______
|__H1__|__H2__|__H3__|__H4__|  
|      |      |      |      |
|      |      |      |      | 
|      |      |      |      |
|      |      |      |      | 

There needs to be a gap from the footer so I cannot use a line in the page footer. Also If I do use a line in the page footer, the last row of the report will not have a bottom border.

Is there a way to conditionally enable the Bottom border based on the row being the last row of the page?

screenshot of the report

like image 210
Prakash Ar Avatar asked Jan 19 '26 06:01

Prakash Ar


1 Answers

Draw the line then columnFooter Band and set isFloatColumnFooter="true"

isFloatColumnFooter=true, render column footer just below the last detail or group footer on that particular column

Example

<?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="Blank_A4_8" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isFloatColumnFooter="true" uuid="28bc671c-47fc-4083-8211-a3f952643349">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="5 empty records"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <columnHeader>
        <band height="1">
            <line>
                <reportElement x="0" y="0" width="300" height="1" uuid="226f98ce-bb08-4741-a5af-3073ce2aee3a"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
        </band>
    </columnHeader>
    <detail>
        <band height="30" splitType="Stretch">
            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
            <textField>
                <reportElement x="150" y="0" width="150" height="30" uuid="5279e4bc-05ce-46d7-b4cf-ef703d105d92">
                    <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                </reportElement>
                <box padding="5">
                    <topPen lineWidth="0.0"/>
                    <leftPen lineWidth="0.5"/>
                    <rightPen lineWidth="0.5"/>
                </box>
                <textElement verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA["Text Field " + $V{REPORT_COUNT}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="0" width="150" height="30" uuid="96e9515f-fab2-483d-926b-6bc799199562"/>
                <box padding="5">
                    <topPen lineWidth="0.0"/>
                    <leftPen lineWidth="0.5"/>
                    <rightPen lineWidth="0.5"/>
                </box>
                <textElement verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band height="1" splitType="Stretch">
            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
            <line>
                <reportElement x="0" y="0" width="300" height="1" uuid="226f98ce-bb08-4741-a5af-3073ce2aee3a"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
        </band>
    </columnFooter>
</jasperReport>

Output (running with a 5 record empty datasource)

Result

Note, when creating reports as invoice's etc, with fix lines on page (that does not depend on datasource) the background band can be used.

like image 95
Petter Friberg Avatar answered Jan 21 '26 19:01

Petter Friberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!