punitware Posted May 21, 2021 Share Posted May 21, 2021 Hello All,I am new to Jaspersoft and need help on one how to print data in column to save space on report. Below is my requirement.We are desiginging report to print Cities travelled by person in 1 month. Example Mr Atravelled to 6 cities in a month and Mrs B tavelled 3 cities. So we want to print the same as shown below MR A City 1City 2City 3City 4 City 5City 6 Mrs BCity 1City 2City 3 Basically we want to pint cities in columns instead of rows, but SQL is returning cities in Row Link to comment Share on other sites More sharing options...
reachrekhakn Posted June 3, 2021 Share Posted June 3, 2021 One option is you could have the values in one column but comma-separated and have the text in the column warp to the next row. It will not come as separate columns but can be shown similar to the above, Link to comment Share on other sites More sharing options...
Tom C Posted June 4, 2021 Share Posted June 4, 2021 You can use a report list element to lay out cities horizontally. See sample report:Report data: Simple report layout: Report output: Report design template (JRXML file):<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 7.9.0.final using JasperReports Library version 6.16.0-48579d909b7943b64690c65c71e07e0b80981928 --><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="demo-20210603" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="3e4d9a69-d315-4243-ad30-8f6cef2f29ce"> <property name="com.jaspersoft.studio.data.sql.tables" value=""/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="JRSrepo"/> <property name="com.jaspersoft.studio.property.dataset.dialog.DatasetDialog.sash.w1" value="338"/> <property name="com.jaspersoft.studio.property.dataset.dialog.DatasetDialog.sash.w2" value="651"/> <property name="com.jaspersoft.studio.data.sql.SQLQueryDesigner.sash.w1" value="473"/> <property name="com.jaspersoft.studio.data.sql.SQLQueryDesigner.sash.w2" value="526"/> <subDataset name="Dataset1" uuid="fc1c4348-9a3a-42b2-a750-597914f2db75"> <property name="com.jaspersoft.studio.data.sql.tables" value=""/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="JRSrepo"/> <parameter name="name" class="java.lang.String"> <defaultValueExpression><![CDATA["Mr A"]]></defaultValueExpression> </parameter> <queryString language="SQL"> <![CDATA[select city from (select * from (values ('Mr A','City 1'),('Mr A','City 2'),('Mr A','City 3'),('Mr A','City 4'),('Mr A','City 5'),('Mr A','City 6'),('Mr B','City 1'),('Mr B','City 2'),('Mr B','City 3')) as t (Name,city) order by 1, 2) as reportdatawhere name = $P{name} order by city]]> </queryString> <field name="city" class="java.lang.String"> <property name="com.jaspersoft.studio.field.name" value="city"/> <property name="com.jaspersoft.studio.field.label" value="city"/> </field> </subDataset> <queryString language="SQL"> <![CDATA[select name from (select * from (values ('Mr A','City 1'),('Mr A','City 2'),('Mr A','City 3'),('Mr A','City 4'),('Mr A','City 5'),('Mr A','City 6'),('Mr B','City 1'),('Mr B','City 2'),('Mr B','City 3')) as t (Name,city) order by 1, 2) as reportdatagroup by name]]> </queryString> <field name="name" class="java.lang.String"> <property name="com.jaspersoft.studio.field.name" value="name"/> <property name="com.jaspersoft.studio.field.label" value="name"/> </field> <detail> <band height="30" splitType="Stretch"> <textField> <reportElement x="0" y="0" width="100" height="30" uuid="c18292b9-fff5-4867-b0c6-2d10f095338e"/> <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression> </textField> <componentElement> <reportElement x="100" y="0" width="400" height="30" uuid="103320d3-4fd6-4d03-b189-74d441bb2e3f"> <property name="com.jaspersoft.studio.unit.width" value="px"/> <property name="com.jaspersoft.studio.unit.CONTENTS.width" value="px"/> </reportElement> <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Horizontal"> <datasetRun subDataset="Dataset1" uuid="4d4c98c6-5416-4786-a6d6-2b0fcc4a0926"> <datasetParameter name="name"> <datasetParameterExpression><![CDATA[$F{name}]]></datasetParameterExpression> </datasetParameter> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> </datasetRun> <jr:listContents height="30" width="100"> <textField> <reportElement x="0" y="0" width="100" height="30" uuid="4a917ea1-6b17-4ccc-a722-6c0a9b1e3dae"/> <textFieldExpression><![CDATA[$F{city}]]></textFieldExpression> </textField> </jr:listContents> </jr:list> </componentElement> </band> </detail></jasperReport> Link to comment Share on other sites More sharing options...
punitware Posted June 5, 2021 Author Share Posted June 5, 2021 Hello Tchen,Thank you for giving me example. I copied the.jrxml file but it is giving me null report. Can you share correct .jrxml file. Link to comment Share on other sites More sharing options...
Tom C Posted June 5, 2021 Share Posted June 5, 2021 With all due respect, the sample is not a fake report but the content of a "correct"/working/tested report template jrxml file. You just need a (any) PostgreSQL data source to test run it in Jaspersoft Studio (JSS) and produce the result as shown in my posting. The intention here is to show users how this can be accomplished using JasperReports engine (JRL) to meet your particular requirement. Please refer to Jaspoersoft Studio User Guide to learn how the product is supposed to work in general. https://community.jaspersoft.com/documentation/tibco-jaspersoft-studio-user-guide/v790/getting-started-jaspersoft-studio You can also review many of Jaspersoft studio tutorial videos from the user community on YouTube to get yourself familiar with the features and capabilities of our product. Hope this provides enough guidance level information and helps to steer you into the right direction. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now