2006 JR Open Discussion Posted August 22, 2006 Share Posted August 22, 2006 By: chenwj - cwscwj couldnt save my crosstab, xml codes r changed 2006-04-24 20:06i use Ireport(1.2 edition) to open a demo named of shipmentReport.jrxml which is located in demo folder of jasperreport project.., its original xml codes displays : ********************************** <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="ShipmentsReport" 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_Large" isDefault="false" style="Arial_Normal" fontSize="10"/> <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="Country_Orders"> <parameter name="Country" class="java.lang.String"/> <queryString><![CDATA[ SELECT ShippedDate, ShipRegion, ShipCity, Freight FROM Orders WHERE ShipCountry = $P{Country} AND ShippedDate IS NOT NULL ]]></queryString> <field name="ShippedDate" class="java.sql.Timestamp"/> <field name="ShipRegion" class="java.lang.String"/> <field name="ShipCity" class="java.lang.String"/> <field name="Freight" class="java.lang.Float"/> </subDataset> <queryString><![CDATA[ SELECT DISTINCT ShipCountry FROM Orders ]]></queryString> <field name="ShipCountry" class="java.lang.String"/> <detail> <band height="50"> <textField> <reportElement x="0" y="0" width="500" height="15"/> <textElement> <font fontName="Arial_Bold" size="10"/> </textElement> <textFieldExpression>"Shipments to " + $F{ShipCountry}</textFieldExpression> </textField> <crosstab isRepeatColumnHeaders="false"> <reportElement x="0" y="20" width="812" height="20"/> <crosstabParameter name="Country" class="java.lang.String"> <parameterValueExpression>$F{ShipCountry}</parameterValueExpression> </crosstabParameter> <crosstabDataset> <dataset> <datasetRun subDataset="Country_Orders"> <datasetParameter name="Country"> <datasetParameterExpression><![CDATA[$F{ShipCountry}]]></datasetParameterExpression> </datasetParameter> </datasetRun> </dataset> </crosstabDataset> <crosstabHeaderCell> <cellContents> <box border="2Point"/> <staticText> <reportElement x="4" y="4" width="112" height="42" style="Arial_Large"/> <textElement textAlignment="Center" verticalAlignment="Middle"/> <text>Shipments total freight</text> </staticText> </cellContents> </crosstabHeaderCell> <rowGroup name="Region" width="50" totalPosition="End"> <bucket> <bucketExpression class="java.lang.String">$F{ShipRegion}</bucketExpression> </bucket> <crosstabRowHeader> <cellContents> <box leftBorder="2Point" bottomBorder="2Point" rightBorder="2Point"/> <textField> <reportElement x="5" y="5" width="40" height="26"/> <textFieldExpression><![CDATA[$V{Region} == null ? "No region" : $V{Region}]]></textFieldExpression> </textField> </cellContents> </crosstabRowHeader> <crosstabTotalRowHeader> <cellContents backcolor="#60FFFF" mode="Opaque"> <box leftBorder="2Point" bottomBorder="2Point" rightBorder="2Point"/> <textField> <reportElement x="5" y="0" width="110" height="22"/> <textElement verticalAlignment="Middle"/> <textFieldExpression>$P{Country} + " Total"</textFieldExpression> </textField> </cellContents> </crosstabTotalRowHeader> </rowGroup> <rowGroup name="City" width="70" totalPosition="End"> <bucket> <bucketExpression class="java.lang.String">$F{ShipCity}</bucketExpression> </bucket> <crosstabRowHeader> <cellContents> <box bottomBorder="2Point" rightBorder="2Point"/> <textField> <reportElement x="5" y="0" width="60" height="16"/> <textElement verticalAlignment="Middle"/> <textFieldExpression>$V{City}</textFieldExpression> </textField> </cellContents> </crosstabRowHeader> <crosstabTotalRowHeader> <cellContents backcolor="#E0FFFF" mode="Opaque"> <box bottomBorder="2Point" rightBorder="2Point"/> <staticText> <reportElement x="5" y="0" width="60" height="20"/> <textElement verticalAlignment="Middle"/> <text>Total</text> </staticText> </cellContents> </crosstabTotalRowHeader> </rowGroup> <columnGroup name="ShipYear" height="25" totalPosition="End" headerPosition="Stretch"> <bucket> <bucketExpression class="java.util.Date">CrosstabApp.truncateToYear($F{ShippedDate})</bucketExpression> </bucket> <crosstabColumnHeader> <cellContents> <box topBorder="2Point" bottomBorder="2Point" rightBorder="2Point"/> <rectangle radius="10"> <reportElement x="4" y="4" width="52" height="17"/> <graphicElement pen="1Point"/> </rectangle> <textField pattern="yyyy"> <reportElement x="5" y="5" width="50" height="15"/> <textElement textAlignment="Center" verticalAlignment="Middle"/> <textFieldExpression class="java.util.Date">$V{ShipYear}</textFieldExpression> </textField> </cellContents> </crosstabColumnHeader> <crosstabTotalColumnHeader> <cellContents backcolor="#FFFF60" mode="Opaque"> <box topBorder="2Point" bottomBorder="2Point" rightBorder="2Point"/> <staticText> <reportElement x="5" y="5" width="20" height="15"/> <text>Total</text> </staticText> </cellContents> </crosstabTotalColumnHeader> </columnGroup> <columnGroup name="ShipMonth" height="25" totalPosition="End"> <bucket> <bucketExpression class="java.util.Date">CrosstabApp.truncateToMonth($F{ShippedDate})</bucketExpression> </bucket> <crosstabColumnHeader> <cellContents> <box bottomBorder="2Point" rightBorder="2Point"/> <textField pattern="MMM"> <reportElement x="5" y="2" width="20" height="21"/> <textFieldExpression class="java.util.Date">$V{ShipMonth}</textFieldExpression> </textField> </cellContents> </crosstabColumnHeader> <crosstabTotalColumnHeader> <cellContents backcolor="#FFFFC0" mode="Opaque"> <box bottomBorder="2Point" rightBorder="2Point"/> <textField> <reportElement x="5" y="2" width="20" height="21"/> <textFieldExpression>msg("{0,date,yyyy} Total", $V{ShipYear})</textFieldExpression> </textField> </cellContents> </crosstabTotalColumnHeader> </columnGroup> <measure name="FreightSum" class="java.lang.Float" calculation="Sum"> <measureExpression>$F{Freight}</measureExpression> </measure> <crosstabCell width="30" height="16"> <cellContents backcolor="#FFFFFF" mode="Opaque"> <box bottomBorder="1Point" rightBorder="1Point"/> <textField pattern="#0.0"> <reportElement x="0" y="0" width="25" height="16"/> <textElement textAlignment="Right" verticalAlignment="Middle"/> <textFieldExpression class="java.lang.Float">$V{FreightSum}</textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell width="30" columnTotalGroup="ShipMonth"> <cellContents backcolor="#FFFFC0" mode="Opaque"> <box bottomBorder="1Point" rightBorder="1Point"/> <textField pattern="#0.0"> <reportElement x="0" y="0" width="25" height="16" style="Arial_Bold"/> <textElement textAlignment="Right" verticalAlignment="Middle"/> <textFieldExpression class="java.lang.Float">$V{FreightSum}</textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell width="35" columnTotalGroup="ShipYear"> <cellContents backcolor="#FFFF60" mode="Opaque"> <box bottomBorder="1Point" rightBorder="1Point"/> <textField pattern="#0.0"> <reportElement x="0" y="0" width="30" height="16" style="Arial_Bold"/> <textElement textAlignment="Right" verticalAlignment="Middle"/> <textFieldExpression class="java.lang.Float">$V{FreightSum}</textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell height="20" rowTotalGroup="City"> <cellContents backcolor="#E0FFFF" mode="Opaque"> <box bottomBorder="1Point" rightBorder="1Point"/> <textField pattern="#0.0"> <reportElement x="0" y="0" width="25" height="20"/> <textElement textAlignment="Right" verticalAlignment="Middle"/> <textFieldExpression class="java.lang.Float">$V{FreightSum}</textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell rowTotalGroup="City" columnTotalGroup="ShipMonth"> <cellContents backcolor="#E0FFC0" mode="Opaque"> <box bottomBorder="1Point" rightBorder="1Point"/> <textField pattern="#0.0"> <reportElement x="0" y="0" width="25" height="20" style="Arial_Bold"/> <textElement textAlignment="Right" verticalAlignment="Middle"/> <textFieldExpression class="java.lang.Float">$V{FreightSum}</textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell rowTotalGroup="City" columnTotalGroup="ShipYear"> <cellContents backcolor="#E0FF60" mode="Opaque"> <box bottomBorder="1Point" rightBorder="1Point"/> <textField pattern="#0.0"> <reportElement x="0" y="0" width="30" height="20" style="Arial_Bold"/> <textElement textAlignment="Right" verticalAlignment="Middle"/> <textFieldExpression class="java.lang.Float">$V{FreightSum}</textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell height="24" rowTotalGroup="Region"> <cellContents backcolor="#60FFFF" mode="Opaque"> <box bottomBorder="1Point" rightBorder="1Point"/> <textField pattern="#0.0"> <reportElement x="0" y="0" width="25" height="12" style="Arial_Bold"/> <textElement textAlignment="Right" verticalAlignment="Bottom"/> <textFieldExpression class="java.lang.Float">$V{FreightSum}</textFieldExpression> </textField> <textField> <reportElement x="0" y="12" width="25" height="12" style="Arial_Bold"/> <textElement textAlignment="Right"/> <textFieldExpression>msg("({0,number,percent})", new Float($V{FreightSum}.floatValue() / $V{FreightSum_ShipYear_ALL}.floatValue()))</textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell rowTotalGroup="Region" columnTotalGroup="ShipMonth"> <cellContents backcolor="#60FFC0" mode="Opaque"> <box bottomBorder="1Point" rightBorder="1Point"/> <textField pattern="#0.0"> <reportElement x="0" y="0" width="25" height="12" style="Arial_Bold"/> <textElement textAlignment="Right" verticalAlignment="Bottom"/> <textFieldExpression class="java.lang.Float">$V{FreightSum}</textFieldExpression> </textField> <textField> <reportElement x="0" y="12" width="25" height="12" style="Arial_Bold"/> <textElement textAlignment="Right"/> <textFieldExpression>msg("({0,number,percent})", new Float($V{FreightSum}.floatValue() / $V{FreightSum_ShipYear_ALL}.floatValue()))</textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell rowTotalGroup="Region" columnTotalGroup="ShipYear"> <cellContents backcolor="#60FF60" mode="Opaque"> <box bottomBorder="1Point" rightBorder="1Point"/> <textField pattern="#0.0"> <reportElement x="0" y="0" width="30" height="12" style="Arial_Bold"/> <textElement textAlignment="Right" verticalAlignment="Bottom"/> <textFieldExpression class="java.lang.Float">$V{FreightSum}</textFieldExpression> </textField> <textField> <reportElement x="0" y="12" width="30" height="12" style="Arial_Bold"/> <textElement textAlignment="Right"/> <textFieldExpression>msg("({0,number,percent})", new Float($V{FreightSum}.floatValue() / $V{FreightSum_ShipYear_ALL}.floatValue()))</textFieldExpression> </textField> </cellContents> </crosstabCell> </crosstab> </band> </detail> </jasperReport> *************************************** as i repeted save shipmentReport.jrxml again without any changes , the xml codes r changed to ______________________ <?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="ShipmentsReport" columnCount="1" printOrder="Vertical" orientation="Landscape" pageWidth="842" pageHeight="595" columnWidth="812" columnSpacing="0" leftMargin="15" rightMargin="15" topMargin="10" bottomMargin="10" 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 DISTINCT ShipCountry FROM Orders]]></queryString> <field name="ShipCountry" 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="50" isSplitAllowed="true" > <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Transparent" x="0" y="0" width="500" height="15" forecolor="#000000" backcolor="#FFFFFF" key="textField" stretchType="NoStretch" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Arial_Bold" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["Shipments to " + $F{ShipCountry}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="0" isSplitAllowed="true" > </band> </pageFooter> <summary> <band height="0" isSplitAllowed="true" > </band> </summary> </jasperReport> ____________________________________ i dont know why its xml codes r differ to the origial one , ... a urgent issue.. many thanks~!!!!!!!! By: chenwj - cwscwj RE: couldnt save my crosstab, xml codes r changed 2006-04-25 18:50as i complied the shipmentReport.jrxml ,it occured the err like that " Element type "crosstabHeaderCell" must be declared.", but i check that it 's really have a declaration on element crosstabHeaderCell in its .dtd file like this"<!ELEMENT crosstabHeaderCell (cellContents)>", i really need your help, many thanks again By: chenwj - cwscwj RE: couldnt save my crosstab, xml codes r changed 2006-04-27 18:39remark my issue again,,anyone could give me some suggesionts on how to slove it , thanks a lot 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