Hi all,
I have this requirement to generate a report with dynamic columns which is the course code. I manage to do this with the crosstab.
But I have another extra details (GPA,CGPA,Result) which require me to add extra column to the crosstab.The data is retrieved from the database already. I'm not able to do this as there is no option for this.
So any idea on how I can add extra column to the crosstab?
Thanks
3 Answers:
Posted on August 25, 2017 at 10:54am
I wasn't able to find a way to add a column without a group, so did the following work around:
In my last column
- I added a second text field element in the Column Group header
- CrossTab > Column Groups > Total DateData.Date: This section contains two text fields
<columnGroup name="dateSet.RecordDate" height="20" totalPosition="End"> <bucket order="Descending" class="java.sql.Timestamp"> <bucketExpression><![CDATA[$F{dateSet.RecordDate}]]></bucketExpression> </bucket> <crosstabHeader> <cellContents> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/> </cellContents> </crosstabHeader> <crosstabColumnHeader> <cellContents mode="Opaque" style="Crosstab_CH"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/> <property name="com.jaspersoft.studio.unit.width" value="pixel"/> <textField pattern="MMM d, yyyy"> <reportElement mode="Opaque" x="0" y="0" width="70" height="20" forecolor="#FFFFFF" backcolor="#0096D1" uuid="b9639ac1-d6ff-41fd-b066-534a881548a2"/> <textFieldExpression><![CDATA[$V{dateSet.RecordDate}]]></textFieldExpression> </textField> </cellContents> </crosstabColumnHeader> <crosstabTotalColumnHeader> <cellContents mode="Opaque" style="Crosstab_CT"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/> <property name="com.jaspersoft.studio.unit.width" value="pixel"/> <textField> <reportElement mode="Opaque" x="0" y="0" width="60" height="20" forecolor="#FFFFFF" backcolor="#0096D1" uuid="b7d8e730-8fca-4b37-b6c0-6d2732444fea"/> <textFieldExpression><![CDATA["\u0394"]]></textFieldExpression> </textField> <textField> <reportElement mode="Opaque" x="60" y="0" width="60" height="20" forecolor="#FFFFFF" backcolor="#0096D1" uuid="b6884931-0695-4142-9d49-34989de70de2"/> <textFieldExpression><![CDATA["Abs " + "\u0394"]]></textFieldExpression> </textField> </cellContents> </crosstabTotalColumnHeader> </columnGroup>
- I added a second text field element in the Column Group Detail section
- CrossTab > DateData.Date/Detail: This section contains two text fields, with each of my $V{Variable_Measures}
<crosstabCell width="120" height="20" columnTotalGroup="dateSet.RecordDate"> <cellContents mode="Opaque" style="Crosstab_CT"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/> <textField pattern="#,##0.00"> <reportElement mode="Opaque" x="0" y="0" width="60" height="20" forecolor="#000000" uuid="a753ecb5-d682-4ffc-8f41-3b4e8f6cce98"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font fontName="DejaVu Sans" size="10"/> </textElement> <textFieldExpression><![CDATA[$V{Diff_Measure}]]></textFieldExpression> </textField> <textField pattern="#,##0.00"> <reportElement mode="Opaque" x="60" y="0" width="60" height="20" forecolor="#000000" uuid="01e6bcd2-b0e4-4bb7-a353-6221af88415b"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font fontName="DejaVu Sans" size="10"/> </textElement> <textFieldExpression><![CDATA[$V{AbsDiff_Measure}]]></textFieldExpression> </textField> </cellContents> </crosstabCell>
- Apologies, i don't seem to have permission to upload a screenshot, but src code above
- Im sure it's more complicated when your crosstab contains totals, mine was fortunately a very simple crosstab
Hi.. Can you guide me on doing this. I dont see any add new column in jasperstudio. All I see is to add column group and row group which really wasn't what I'm looking for..
never mind.. I already achieve something.. Thanks. :D