Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jasper Report Column Layout

I have a Jasper Report that has a single detail section, and inside the detail section is a single field from the database that gets printed. So if my query returns 100 rows, I get 100 lines, which produces a report about 10 pages long, since 10 records fit on a page.

Is there a way I can print that field in columns, so that I can fit, say, 40 records on the page, instead of just 10? (By having 4 columns of 10)

like image 833
user1154644 Avatar asked Jan 30 '13 15:01

user1154644


People also ask

How do I add dynamic columns in Jasper report?

In Jasper Report, you can use 'printWhenExpression' where you can print a particular row/column/value based on a certain condition. If you know the max no. of columns then add those columns in your design and then hide them using printWhenExpression.

How do I group columns in Jasper report?

right click on the report in the report inspector and choose Add Report Group. Follow the wizard, set as group name PledgeType and choose Group by the following report object where you select the field PledgeType. Click next. Check Add the group header and click Finish.

How do I add a column to a Jasper report?

To add a column to a table, right-click the column and choose Create Column After, Create Column Before, Create Column at the Beginning, or Create Column At The End. By default, when Jaspersoft Studio adds a column to a table, the new column inherits the properties of the other columns in the table.


1 Answers

You can configure a multi-column report. If you are using iReport, right click in the Report Inspector on the report name and select Page Format. In the Columns Section increase Columns from 1 to 4, if desired configure Space to define a distance between the columns. If you click on the report you can also choose the Print order in the Properties panel.

In the report designer you drag the field in the first column in the detail band.

the added properties in the JRXML are in the <jasperreports ... tag:

  • columnCount="4": 4 columns
  • printOrder="Horizontal": fill order is horizontal.

Attached the JRXML for further reference:

<?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="report8" language="groovy" columnCount="4" printOrder="Horizontal" pageWidth="595" pageHeight="842" columnWidth="138" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="5e2835cc-bc36-4f77-8631-08a8deaa28d7">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <queryString>
        <![CDATA[select 'A' as field]]>
    </queryString>
    <field name="field" class="java.lang.String"/>
    <detail>
        <band height="20" splitType="Stretch">
            <textField>
                <reportElement uuid="76707cdd-7dbe-477e-b3a4-38f9ba3bd003" x="0" y="0" width="136" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{field}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>
like image 57
MrsTang Avatar answered Sep 20 '22 13:09

MrsTang