I'm new at iReport. In my project, i need to design two reports as follows. I use crosstab to present both but I have some problem with it. Please help me out. The deadline is coming :((
|
Jan |
Feb |
||
Produce |
Sell |
Produce |
Sell |
|
Product A |
10 |
5 |
12 |
6 |
Product B |
5 |
2 |
2 |
5 |
With this report, I can not horizontally stretch header cell Jan/Feb to fix with Produce+Sell like the figure.i.e. Produce=Sell=50 and Jan=100, but with crosstab I can only set maximun of Jan is 50.
|
Product A |
Product B |
|
Jan |
Produce |
10 |
5 |
Sell |
5 |
2 |
|
Feb |
Produce |
12 |
2 |
Sell |
6 |
5 |
With this report, I can vertically stretch header cell Jan/Feb.The alignment of crosstab when I preview in iReport is okb ut it is not proper in web. The Jan cell is stretched but it's height is not fix with the total height of Produce and Sell.
Note: I checked "Stretch with overflow" with stretch type is "Relative to band height'.
Thanks in advance.
7 Answers:
Yes, this is doable. What you probably need is a "union" in your query. For example
Notice how I have added a new field called "Type". Now simply add a row group on "Product" and Column groups on "Date" and "Type" and for the calculation add a "Sum" for the "Count_" field.
That should do the trick.
Hope this helps!
kchaudhry
Code: |
select 'A' as 'Product', '04/08/2009' as 'Date', 10 as 'Count', 'Produce' as 'Type' union select 'A' as 'Product', '04/08/2009' as 'Date', 5 as 'Count', 'Sold' as 'Type'</td></tr></tbody></table><br><br>Post Edited by kchaudhry at 04/21/2009 15:07 |
First of all, please don't edit your original post to ask a different question. This can be misleading to other users since the response provided will not relate to the question.
Now coming to your question, you can highlight your date element and click on "Enlarge between margins". If this doesn't solve your problem then post your jrxml here.
Sorry kchaudhry,
but seem it doesn't work to my report. With ireport 3.0.0 I tried "Enlarge between margins", the element width changed to 100 but I got error when compiling the code "Element reaches outside Date header width..."
With ireport 3.5.0 I tried "Adapt to parent" but it didn't work too...
Enlosed is the jrxml file.
Thanks
Code: |
<?xml version="1.0" encoding="UTF-8" ?> <!-- Created with iReport - A designer for JasperReports --> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="Untitled_report_1" columnCount="1" printOrder="Vertical" orientation="Landscape" pageWidth="842" pageHeight="595" columnWidth="782" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <queryString><![CDATA[select 'A' as "Product", '04/08/2009' as "Date", 10 as "Count", 'Produce' as "Type" from dual union select 'A' as "Product", '04/08/2009' as "Date", 5 as "Count", 'Sold' as "Type" from dual]]></queryString> <field name="Product" class="java.lang.String"/> <field name="Date" class="java.lang.String"/> <field name="Count" class="java.math.BigDecimal"/> <field name="Type" class="java.lang.String"/> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="0" isSplitAllowed="true" > </band> </title> <pageHeader> <band height="0" isSplitAllowed="true" > </band> </pageHeader> <columnHeader> <band height="0" isSplitAllowed="true" > </band> </columnHeader> <detail> <band height="0" isSplitAllowed="true" > </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="0" isSplitAllowed="true" > </band> </pageFooter> <summary> <band height="200" isSplitAllowed="true" > <crosstab > <reportElement x="0" y="1" width="782" height="198" key="crosstab-1"/> <crosstabHeaderCell> <cellContents mode="Transparent"> <box></box> </cellContents> </crosstabHeaderCell> <rowGroup name="Product" width="100"> <bucket> <bucketExpression class="java.lang.String"><![CDATA[$F{Product}]]></bucketExpression> </bucket> <crosstabRowHeader> <cellContents mode="Transparent"> <box></box> <textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="100" height="30" key="textField" stretchType="RelativeToBandHeight" positionType="Float" isPrintRepeatedValues="false"/> <box> <topPen lineWidth="0.5"/> <leftPen lineWidth="0.5"/> <bottomPen lineWidth="0.5"/> <rightPen lineWidth="0.5"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$V{Product}]]></textFieldExpression> </textField> </cellContents> </crosstabRowHeader> <crosstabTotalRowHeader> <cellContents mode="Transparent"> <box></box> </cellContents> </crosstabTotalRowHeader> </rowGroup> <columnGroup name="Date" height="25" headerPosition="Center"> <bucket> <bucketExpression class="java.lang.String"><![CDATA[$F{Date}]]></bucketExpression> </bucket> <crosstabColumnHeader> <cellContents mode="Transparent"> <box></box> <textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="100" height="25" key="textField" stretchType="RelativeToBandHeight" positionType="Float" isPrintRepeatedValues="false"/> <box> <topPen lineWidth="0.5"/> <leftPen lineWidth="0.5"/> <bottomPen lineWidth="0.5"/> <rightPen lineWidth="0.5"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$V{Date}]]></textFieldExpression> </textField> </cellContents> </crosstabColumnHeader> <crosstabTotalColumnHeader> <cellContents mode="Transparent"> <box></box> </cellContents> </crosstabTotalColumnHeader> </columnGroup> <columnGroup name="Type" height="25" headerPosition="Center"> <bucket> <bucketExpression class="java.lang.String"><![CDATA[$F{Type}]]></bucketExpression> </bucket> <crosstabColumnHeader> <cellContents mode="Transparent"> <box></box> <textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="50" height="25" key="textField" stretchType="RelativeToBandHeight" positionType="Float" isPrintRepeatedValues="false"/> <box> <topPen lineWidth="0.5"/> <leftPen lineWidth="0.5"/> <bottomPen lineWidth="0.5"/> <rightPen lineWidth="0.5"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$V{Type}]]></textFieldExpression> </textField> </cellContents> </crosstabColumnHeader> <crosstabTotalColumnHeader> <cellContents mode="Transparent"> <box></box> </cellContents> </crosstabTotalColumnHeader> </columnGroup> <measure name="Count_Nothing" class="java.math.BigDecimal"> <measureExpression><![CDATA[$F{Count}]]></measureExpression> </measure> <crosstabCell width="50" height="30"> <cellContents mode="Transparent"> <box></box> <textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="50" height="30" key="textField" stretchType="RelativeToBandHeight" positionType="Float" isPrintRepeatedValues="false"/> <box> <topPen lineWidth="0.5"/> <leftPen lineWidth="0.5"/> <bottomPen lineWidth="0.5"/> <rightPen lineWidth="0.5"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{Count_Nothing}]]></textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell width="50" height="30" columnTotalGroup="Type"> <cellContents mode="Transparent"> <box></box> <textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="50" height="30" key="textField" stretchType="RelativeToBandHeight" positionType="Float" isPrintRepeatedValues="false"/> <box> <topPen lineWidth="0.5"/> <leftPen lineWidth="0.5"/> <bottomPen lineWidth="0.5"/> <rightPen lineWidth="0.5"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{Count_Nothing}]]></textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell width="50" height="30" columnTotalGroup="Date"> <cellContents mode="Transparent"> <box></box> <textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="50" height="30" key="textField" stretchType="RelativeToBandHeight" positionType="Float" isPrintRepeatedValues="false"/> <box> <topPen lineWidth="0.5"/> <leftPen lineWidth="0.5"/> <bottomPen lineWidth="0.5"/> <rightPen lineWidth="0.5"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{Count_Nothing}]]></textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell width="50" height="30" rowTotalGroup="Product"> <cellContents mode="Transparent"> <box></box> <textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="50" height="30" key="textField" stretchType="RelativeToBandHeight" positionType="Float" isPrintRepeatedValues="false"/> <box> <topPen lineWidth="0.5"/> <leftPen lineWidth="0.5"/> <bottomPen lineWidth="0.5"/> <rightPen lineWidth="0.5"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{Count_Nothing}]]></textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell width="50" height="30" rowTotalGroup="Product" columnTotalGroup="Type"> <cellContents mode="Transparent"> <box></box> <textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="50" height="30" key="textField" stretchType="RelativeToBandHeight" positionType="Float" isPrintRepeatedValues="false"/> <box> <topPen lineWidth="0.5"/> <leftPen lineWidth="0.5"/> <bottomPen lineWidth="0.5"/> <rightPen lineWidth="0.5"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{Count_Nothing}]]></textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell width="50" height="30" rowTotalGroup="Product" columnTotalGroup="Date"> <cellContents mode="Transparent"> <box></box> <textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="50" height="30" key="textField" stretchType="RelativeToBandHeight" positionType="Float" isPrintRepeatedValues="false"/> <box> <topPen lineWidth="0.5"/> <leftPen lineWidth="0.5"/> <bottomPen lineWidth="0.5"/> <rightPen lineWidth="0.5"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{Count_Nothing}]]></textFieldExpression> </textField> </cellContents> </crosstabCell> <whenNoDataCell> <cellContents mode="Transparent"> <box></box> </cellContents> </whenNoDataCell> </crosstab> </band> </summary> </jasperReport> <!-- Created with iReport - A designer for JasperReports --> <jasperreport name="Untitled_report_1" columncount="1" printorder="Vertical" orientation="Landscape" pagewidth="842" pageheight="595" columnwidth="782" columnspacing="0" leftmargin="30" rightmargin="30" topmargin="20" bottommargin="20" whennodatatype="NoPages" istitlenewpage="false" issummarynewpage="false"><br /> <property name="ireport.scriptlethandling" value="0"></property><br /> <property name="ireport.encoding" value="UTF-8"></property><br /> <import value="java.util.*"></import><br /> <import value="net.sf.jasperreports.engine.*"></import><br /> <import value="net.sf.jasperreports.engine.data.*"></import><br /><br /> <querystring><!--[CDATA[select 'A' as "Product", '04/08/2009' as "Date", 10 as "Count", 'Produce' as "Type" from dual union select 'A' as "Product", '04/08/2009' as "Date", 5 as "Count", 'Sold' as "Type" from dual]]--></querystring><br /><br /> <field name="Product" class="java.lang.String"></field><br /> <field name="Date" class="java.lang.String"></field><br /> <field name="Count" class="java.math.BigDecimal"></field><br /> <field name="Type" class="java.lang.String"></field><br /><br /> <background><br /> <band height="0" issplitallowed="true"><br /> </band><br /> </background><title></title><br /> <br /> <pageheader><br /> <band height="0" issplitallowed="true"><br /> </band><br /> </pageheader><br /> <columnheader><br /> <band height="0" issplitallowed="true"><br /> </band><br /> </columnheader><br /> <detail><br /> <band height="0" issplitallowed="true"><br /> </band><br /> </detail><br /> <columnfooter><br /> <band height="0" issplitallowed="true"><br /> </band><br /> </columnfooter><br /> <pagefooter><br /> <band height="0" issplitallowed="true"><br /> </band><br /> </pagefooter><br /> <summary><br /> <band height="200" issplitallowed="true"><br /> <crosstab><br /> <reportelement x="0" y="1" width="782" height="198" key="crosstab-1"></reportelement><br /> <crosstabheadercell> <cellcontents mode="Transparent"><br /> <box></box><br /> </cellcontents><br /> </crosstabheadercell> <rowgroup name="Product" width="100"><br /> <bucket><br /> <bucketexpression class="java.lang.String"><!--[CDATA[$F{Product}]]--></bucketexpression><br /> </bucket><br /> <crosstabrowheader><br /> <cellcontents mode="Transparent"><br /> <box></box><br /> <textfield isstretchwithoverflow="true" isblankwhennull="true" evaluationtime="Now" hyperlinktype="None" hyperlinktarget="Self"><br /> <reportelement x="0" y="0" width="100" height="30" key="textField" stretchtype="RelativeToBandHeight" positiontype="Float" isprintrepeatedvalues="false"></reportelement><br /> <box> <toppen linewidth="0.5"></toppen><br /> <leftpen linewidth="0.5"></leftpen><br /> <bottompen linewidth="0.5"></bottompen><br /> <rightpen linewidth="0.5"></rightpen><br /></box><br /> <textelement textalignment="Center" verticalalignment="Middle"><br /> <br /> </textelement><br /> <textfieldexpression class="java.lang.String"><!--[CDATA[$V{Product}]]--></textfieldexpression><br /> </textfield><br /> </cellcontents><br /> </crosstabrowheader><br /> <crosstabtotalrowheader><br /> <cellcontents mode="Transparent"><br /> <box></box><br /> </cellcontents><br /> </crosstabtotalrowheader><br /> </rowgroup><br /> <columngroup name="Date" height="25" headerposition="Center"><br /> <bucket><br /> <bucketexpression class="java.lang.String"><!--[CDATA[$F{Date}]]--></bucketexpression><br /> </bucket><br /> <crosstabcolumnheader><br /> <cellcontents mode="Transparent"><br /> <box></box><br /> <textfield isstretchwithoverflow="true" isblankwhennull="true" evaluationtime="Now" hyperlinktype="None" hyperlinktarget="Self"><br /> <reportelement x="0" y="0" width="100" height="25" key="textField" stretchtype="RelativeToBandHeight" positiontype="Float" isprintrepeatedvalues="false"></reportelement><br /> <box> <toppen linewidth="0.5"></toppen><br /> <leftpen linewidth="0.5"></leftpen><br /> <bottompen linewidth="0.5"></bottompen><br /> <rightpen linewidth="0.5"></rightpen><br /></box><br /> <textelement textalignment="Center" verticalalignment="Middle"><br /> <br /> </textelement><br /> <textfieldexpression class="java.lang.String"><!--[CDATA[$V{Date}]]--></textfieldexpression><br /> </textfield><br /> </cellcontents><br /> </crosstabcolumnheader><br /> <crosstabtotalcolumnheader><br /> <cellcontents mode="Transparent"><br /> <box></box><br /> </cellcontents><br /> </crosstabtotalcolumnheader><br /> </columngroup><br /> <columngroup name="Type" height="25" headerposition="Center"><br /> <bucket><br /> <bucketexpression class="java.lang.String"><!--[CDATA[$F{Type}]]--></bucketexpression><br /> </bucket><br /> <crosstabcolumnheader><br /> <cellcontents mode="Transparent"><br /> <box></box><br /> <textfield isstretchwithoverflow="true" isblankwhennull="true" evaluationtime="Now" hyperlinktype="None" hyperlinktarget="Self"><br /> <reportelement x="0" y="0" width="50" height="25" key="textField" stretchtype="RelativeToBandHeight" positiontype="Float" isprintrepeatedvalues="false"></reportelement><br /> <box> <toppen linewidth="0.5"></toppen><br /> <leftpen linewidth="0.5"></leftpen><br /> <bottompen linewidth="0.5"></bottompen><br /> <rightpen linewidth="0.5"></rightpen><br /></box><br /> <textelement textalignment="Center" verticalalignment="Middle"><br /> <br /> </textelement><br /> <textfieldexpression class="java.lang.String"><!--[CDATA[$V{Type}]]--></textfieldexpression><br /> </textfield><br /> </cellcontents><br /> </crosstabcolumnheader><br /> <crosstabtotalcolumnheader><br /> <cellcontents mode="Transparent"><br /> <box></box><br /> </cellcontents><br /> </crosstabtotalcolumnheader><br /> </columngroup><br /><br /> <measure name="Count_Nothing" class="java.math.BigDecimal"><br /> <measureexpression><!--[CDATA[$F{Count}]]--></measureexpression><br /> </measure><br /> <crosstabcell width="50" height="30"><br /> <cellcontents mode="Transparent"><br /> <box></box><br /> <textfield isstretchwithoverflow="true" isblankwhennull="true" evaluationtime="Now" hyperlinktype="None" hyperlinktarget="Self"><br /> <reportelement x="0" y="0" width="50" height="30" key="textField" stretchtype="RelativeToBandHeight" positiontype="Float" isprintrepeatedvalues="false"></reportelement><br /> <box> <toppen linewidth="0.5"></toppen><br /> <leftpen linewidth="0.5"></leftpen><br /> <bottompen linewidth="0.5"></bottompen><br /> <rightpen linewidth="0.5"></rightpen><br /></box><br /> <textelement textalignment="Center" verticalalignment="Middle"><br /> <br /> </textelement><br /> <textfieldexpression class="java.math.BigDecimal"><!--[CDATA[$V{Count_Nothing}]]--></textfieldexpression><br /> </textfield><br /> </cellcontents><br /> </crosstabcell><br /> <crosstabcell width="50" height="30" columntotalgroup="Type"><br /> <cellcontents mode="Transparent"><br /> <box></box><br /> <textfield isstretchwithoverflow="true" isblankwhennull="true" evaluationtime="Now" hyperlinktype="None" hyperlinktarget="Self"><br /> <reportelement x="0" y="0" width="50" height="30" key="textField" stretchtype="RelativeToBandHeight" positiontype="Float" isprintrepeatedvalues="false"></reportelement><br /> <box> <toppen linewidth="0.5"></toppen><br /> <leftpen linewidth="0.5"></leftpen><br /> <bottompen linewidth="0.5"></bottompen><br /> <rightpen linewidth="0.5"></rightpen><br /></box><br /> <textelement textalignment="Center" verticalalignment="Middle"><br /> <br /> </textelement><br /> <textfieldexpression class="java.math.BigDecimal"><!--[CDATA[$V{Count_Nothing}]]--></textfieldexpression><br /> </textfield><br /> </cellcontents><br /> </crosstabcell><br /> <crosstabcell width="50" height="30" columntotalgroup="Date"><br /> <cellcontents mode="Transparent"><br /> <box></box><br /> <textfield isstretchwithoverflow="true" isblankwhennull="true" evaluationtime="Now" hyperlinktype="None" hyperlinktarget="Self"><br /> <reportelement x="0" y="0" width="50" height="30" key="textField" stretchtype="RelativeToBandHeight" positiontype="Float" isprintrepeatedvalues="false"></reportelement><br /> <box> <toppen linewidth="0.5"></toppen><br /> <leftpen linewidth="0.5"></leftpen><br /> <bottompen linewidth="0.5"></bottompen><br /> <rightpen linewidth="0.5"></rightpen><br /></box><br /> <textelement textalignment="Center" verticalalignment="Middle"><br /> <br /> </textelement><br /> <textfieldexpression class="java.math.BigDecimal"><!--[CDATA[$V{Count_Nothing}]]--></textfieldexpression><br /> </textfield><br /> </cellcontents><br /> </crosstabcell><br /> <crosstabcell width="50" height="30" rowtotalgroup="Product"><br /> <cellcontents mode="Transparent"><br /> <box></box><br /> <textfield isstretchwithoverflow="true" isblankwhennull="true" evaluationtime="Now" hyperlinktype="None" hyperlinktarget="Self"><br /> <reportelement x="0" y="0" width="50" height="30" key="textField" stretchtype="RelativeToBandHeight" positiontype="Float" isprintrepeatedvalues="false"></reportelement><br /> <box> <toppen linewidth="0.5"></toppen><br /> <leftpen linewidth="0.5"></leftpen><br /> <bottompen linewidth="0.5"></bottompen><br /> <rightpen linewidth="0.5"></rightpen><br /></box><br /> <textelement textalignment="Center" verticalalignment="Middle"><br /> <br /> </textelement><br /> <textfieldexpression class="java.math.BigDecimal"><!--[CDATA[$V{Count_Nothing}]]--></textfieldexpression><br /> </textfield><br /> </cellcontents><br /> </crosstabcell><br /> <crosstabcell width="50" height="30" rowtotalgroup="Product" columntotalgroup="Type"><br /> <cellcontents mode="Transparent"><br /> <box></box><br /> <textfield isstretchwithoverflow="true" isblankwhennull="true" evaluationtime="Now" hyperlinktype="None" hyperlinktarget="Self"><br /> <reportelement x="0" y="0" width="50" height="30" key="textField" stretchtype="RelativeToBandHeight" positiontype="Float" isprintrepeatedvalues="false"></reportelement><br /> <box> <toppen linewidth="0.5"></toppen><br /> <leftpen linewidth="0.5"></leftpen><br /> <bottompen linewidth="0.5"></bottompen><br /> <rightpen linewidth="0.5"></rightpen><br /></box><br /> <textelement textalignment="Center" verticalalignment="Middle"><br /> <br /> </textelement><br /> <textfieldexpression class="java.math.BigDecimal"><!--[CDATA[$V{Count_Nothing}]]--></textfieldexpression><br /> </textfield><br /> </cellcontents><br /> </crosstabcell><br /> <crosstabcell width="50" height="30" rowtotalgroup="Product" columntotalgroup="Date"><br /> <cellcontents mode="Transparent"><br /> <box></box><br /> <textfield isstretchwithoverflow="true" isblankwhennull="true" evaluationtime="Now" hyperlinktype="None" hyperlinktarget="Self"><br /> <reportelement x="0" y="0" width="50" height="30" key="textField" stretchtype="RelativeToBandHeight" positiontype="Float" isprintrepeatedvalues="false"></reportelement><br /> <box> <toppen linewidth="0.5"></toppen><br /> <leftpen linewidth="0.5"></leftpen><br /> <bottompen linewidth="0.5"></bottompen><br /> <rightpen linewidth="0.5"></rightpen><br /></box><br /> <textelement textalignment="Center" verticalalignment="Middle"><br /> <br /> </textelement><br /> <textfieldexpression class="java.math.BigDecimal"><!--[CDATA[$V{Count_Nothing}]]--></textfieldexpression><br /> </textfield><br /> </cellcontents><br /> </crosstabcell><br /> <whennodatacell> <cellcontents mode="Transparent"><br /> <box></box><br /> </cellcontents><br /> </whennodatacell> </crosstab><br /> </band><br /> </summary><br /></jasperreport> |
Post Edited by huynhkchau at 04/22/2009 03:41
Post Edited by huynhkchau at 04/22/2009 03:42
I tried your jrxml and got the same error using ireports 3.0 Then I created another report using your query and it worked fine. I'm not sure why that is happening. I have attached my jrxml.
One thing that I noticed was that you had column and row totals shown on the report while your calculation was set to "Nothing". So I removed those rows and columns as they aren't going to do anything.
Code: |
<?xml version="1.0" encoding="UTF-8" ?> <!-- Created with iReport - A designer for JasperReports --> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="crosstabtest" columnCount="1" printOrder="Vertical" orientation="Landscape" pageWidth="792" pageHeight="612" columnWidth="732" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <queryString><![CDATA[select 'A' as "Product", '04/08/2009' as "Date", 10 as "Count", 'Produce' as "Type" from dual union select 'A' as "Product", '04/08/2009' as "Date", 5 as "Count", 'Sold' as "Type" from dual]]></queryString> <field name="Product" class="java.lang.String"/> <field name="Date" class="java.lang.String"/> <field name="Count" class="java.math.BigDecimal"/> <field name="Type" class="java.lang.String"/> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="0" isSplitAllowed="true" > </band> </title> <pageHeader> <band height="0" isSplitAllowed="true" > </band> </pageHeader> <columnHeader> <band height="0" isSplitAllowed="true" > </band> </columnHeader> <detail> <band height="0" isSplitAllowed="true" > </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="0" isSplitAllowed="true" > </band> </pageFooter> <summary> <band height="200" isSplitAllowed="true" > <crosstab > <reportElement x="0" y="0" width="732" height="200" key="crosstab-1"/> <crosstabHeaderCell> <cellContents mode="Transparent"> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> </cellContents> </crosstabHeaderCell> <rowGroup name="Product" width="100" totalPosition="End"> <bucket> <bucketExpression class="java.lang.String"><![CDATA[$F{Product}]]></bucketExpression> </bucket> <crosstabRowHeader> <cellContents mode="Transparent"> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="100" height="30" key="textField"/> <box></box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$V{Product}]]></textFieldExpression> </textField> </cellContents> </crosstabRowHeader> </rowGroup> <columnGroup name="Date" height="25" headerPosition="Center"> <bucket> <bucketExpression class="java.lang.String"><![CDATA[$F{Date}]]></bucketExpression> </bucket> <crosstabColumnHeader> <cellContents mode="Transparent"> <box> <pen lineWidth="0.25" lineStyle="Solid"/> <topPen lineWidth="0.25" lineStyle="Solid"/> <leftPen lineWidth="0.25" lineStyle="Solid"/> <bottomPen lineWidth="0.25" lineStyle="Solid"/> <rightPen lineWidth="0.25" lineStyle="Solid"/> </box> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="67" height="25" key="textField"/> <box></box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$V{Date}]]></textFieldExpression> </textField> </cellContents> </crosstabColumnHeader> </columnGroup> <columnGroup name="Type" height="25" headerPosition="Center"> <bucket> <bucketExpression class="java.lang.String"><![CDATA[$F{Type}]]></bucketExpression> </bucket> <crosstabColumnHeader> <cellContents mode="Transparent"> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="67" height="25" key="textField"/> <box></box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$V{Type}]]></textFieldExpression> </textField> </cellContents> </crosstabColumnHeader> </columnGroup> <measure name="Count_Nothing" class="java.math.BigDecimal"> <measureExpression><![CDATA[$F{Count}]]></measureExpression> </measure> <crosstabCell width="67" height="30"> <cellContents mode="Transparent"> <box> <pen lineWidth="0.25"/> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="67" height="30" key="textField"/> <box></box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{Count_Nothing}]]></textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell width="0" height="30" columnTotalGroup="Type"> <cellContents mode="Transparent"> <box></box> </cellContents> </crosstabCell> <crosstabCell width="0" height="30" columnTotalGroup="Date"> <cellContents mode="Transparent"> <box></box> </cellContents> </crosstabCell> <crosstabCell width="67" height="0" rowTotalGroup="Product"> <cellContents mode="Transparent"> <box></box> </cellContents> </crosstabCell> <crosstabCell width="0" height="0" rowTotalGroup="Product" columnTotalGroup="Type"> <cellContents mode="Transparent"> <box></box> </cellContents> </crosstabCell> <crosstabCell width="0" height="0" rowTotalGroup="Product" columnTotalGroup="Date"> <cellContents mode="Transparent"> <box></box> </cellContents> </crosstabCell> <whenNoDataCell> <cellContents mode="Transparent"> <box></box> </cellContents> </whenNoDataCell> </crosstab> </band> </summary> </jasperReport></td></tr></tbody></table> |
Hi kchaudhry,
Thanks so much for your support. After reading your file, I solved the problem.:)
As I see, the Date header element is not horizontally stretch only vertically stretch. So instead of bordering the element properties, I border the cell properties and set the Date header width to fix with its output result. The report will look like the above picture.
But anyway, I still hope that header element can auto horizontally stretch :p.
Again,
Thanks