2006 IR Open Dicussion Posted August 26, 2006 Share Posted August 26, 2006 By: kamal - kamalakarareddy crosstab 2006-02-13 14:17 Hi, I am getting the following JRException for a crosstab attached is the .jrxml template. Can any one help me how i can handle this issue? net.sf.jasperreports.engine.JRException: Report design not valid : 1. Element reaches outside RowCommodity header height: y=5, height=40, available height=25. 2. Element reaches outside ColCommodity header width: x=4, width=52, available width=30. 3. Element reaches outside ColCommodity header width: x=5, width=50, available width=30. at net.sf.jasperreports.engine.design.JRAbstractCompiler.verifyDesign(JRAbstractCompiler.java:267) at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:144) at net.sf.jasperreports.engine.design.JRDefaultCompiler.compileReport(JRDefaultCompiler.java:131) at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:127) at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:86) My Template file : <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="CrossTabReport" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="812" leftMargin="15" rightMargin="15" topMargin="10" bottomMargin="10"> <style name="Arial_Normal" isDefault="true" fontName="Arial" fontSize="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <style name="Arial_Bold" isDefault="false" fontName="Arial" fontSize="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <subDataset name="Role_Orders"> <parameter name="RoleName" class="java.lang.String"/> <field name="Commodity" class="java.lang.String"/> <field name="Desc" class="java.lang.Integer"/> <field name="Quantity" class="java.lang.String"/> </subDataset> <parameter name="TabCommDataSource" isForPrompting="true" class="net.sf.jasperreports.engine.JRDataSource"/> <field name="Role" class="java.lang.String"/> <detail> <band height="100"> <textField> <reportElement x="0" y="0" width="812" height="15"/> <textElement textAlignment="Center"> <font fontName="Arial_Bold" size="10"/> </textElement> <textFieldExpression>$F{Role}</textFieldExpression> </textField> <crosstab isRepeatColumnHeaders="false"> <reportElement x="0" y="20" width="812" height="60" mode="Opaque"/> <crosstabParameter name="RoleName" class="java.lang.String"> <parameterValueExpression>$F{Role}</parameterValueExpression> </crosstabParameter> <crosstabDataset> <dataset> <datasetRun subDataset="Role_Orders"> <datasetParameter name="RoleName"> <datasetParameterExpression><![CDATA[$F{Role}]]></datasetParameterExpression> </datasetParameter> <dataSourceExpression><![CDATA[$P{TabCommDataSource}]]></dataSourceExpression> </datasetRun> </dataset> </crosstabDataset> <rowGroup name="RowCommodity" width="50"> <bucket> <bucketExpression class="java.lang.String">$F{Commodity}</bucketExpression> </bucket> <crosstabRowHeader> <cellContents> <box leftBorder="2Point" bottomBorder="2Point" rightBorder="2Point"/> <textField> <reportElement x="5" y="5" width="40" height="40"/> <textFieldExpression><![CDATA[$V{RowCommodity}]]></textFieldExpression> </textField> </cellContents> </crosstabRowHeader> </rowGroup> <columnGroup name="ColCommodity" height="30" headerPosition="Stretch"> <bucket> <bucketExpression class="java.util.Date">$F{Commodity}</bucketExpression> </bucket> <crosstabColumnHeader> <cellContents> <box topBorder="2Point" bottomBorder="2Point" rightBorder="2Point"/> <rectangle radius="10"> <reportElement x="4" y="4" width="52" height="22"/> <graphicElement pen="1Point"/> </rectangle> <textField pattern="yyyy"> <reportElement x="5" y="5" width="50" height="20"/> <textElement textAlignment="Center" verticalAlignment="Middle"/> <textFieldExpression class="java.util.Date">$V{ColCommodity}</textFieldExpression> </textField> </cellContents> </crosstabColumnHeader> </columnGroup> <measure name="QuantitySum" class="java.lang.Integer" calculation="Sum"> <measureExpression>$F{Quantity}</measureExpression> </measure> <crosstabCell width="30" height="25"> <cellContents backcolor="#FFFFFF"> <box bottomBorder="1Point" rightBorder="1Point"/> <textField pattern="#0.0"> <reportElement x="0" y="0" width="25" height="25"/> <textElement textAlignment="Right" verticalAlignment="Middle"/> <textFieldExpression class="java.lang.Float">$V{QuantitySum}</textFieldExpression> </textField> </cellContents> </crosstabCell> </crosstab> </band> </detail> </jasperReport> My Custom data sources : /* * ============================================================================ * GNU Lesser General Public License * ============================================================================ * * JasperReports - Free Java report-generating library. * Copyright © 2001-2005 JasperSoft Corporation http://www.jaspersoft.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * JasperSoft Corporation * 303 Second Street, Suite 450 North * San Francisco, CA 94107 * http://www.jaspersoft.com */ package com.minacsusa; import net.sf.jasperreports.engine.JRDataSource; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRField; public class RoleDataSource implements JRDataSource { /** * */ private Object[][] data = { {"Advisor", new Integer(100), "50"}, {"Technician", new Integer(234), "123"}, {"ABC", new Integer(95), "45"}, }; private int index = -1; /** * */ public RoleDataSource() { } /** * */ public boolean next() throws JRException { index++; return (index < data.length); } /** * */ public Object getFieldValue(JRField field) throws JRException { Object value = null; String fieldName = field.getName(); if ("Role".equals(fieldName)) { value = data[index][0]; } else if ("Dealercount".equals(fieldName)) { value = data[index][1]; } else if ("ActDealercount".equals(fieldName)) { value = data[index][2]; } return value; } } Regards, Kamal. 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