我已经生成了一个报告(使用JasperReport)。我的问题是图表重复,我有一个图表,报告包含22页!有什么问题?
I have generated a report (with JasperReport). My problem that the chart repeats, I have one chart and the report contains 22 pages! What is the problem?
这是我的报告:
<?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="jasperreports.sourceforge/jasperreports" xmlns:xsi="www.w3/2001/XMLSchema-instance" xsi:schemaLocation="jasperreports.sourceforge/jasperreports jasperreports.sourceforge/xsd/jasperreport.xsd" name="report2" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <subDataset name="New Dataset 1"> <parameter name="SQL" class="java.lang.String"/> <parameter name="Titre" class="java.lang.String"> <defaultValueExpression><![CDATA[]]></defaultValueExpression> </parameter> <queryString> <![CDATA[$P!{SQL}]]> </queryString> <field name="nb" class="java.lang.Long"/> <field name="champ1" class="java.lang.String"/> <field name="champ2" class="java.lang.String"/> </subDataset> <parameter name="SQL" class="java.lang.String"> <defaultValueExpression><![CDATA[]]></defaultValueExpression> </parameter> <parameter name="Titre" class="java.lang.String"/> <queryString> <![CDATA[select id from jiraissue]]> </queryString> <field name="id" class="java.math.BigDecimal"/> <background> <band splitType="Stretch"/> </background> <title> <band height="46" splitType="Stretch"> <textField> <reportElement x="89" y="15" width="180" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$P{Titre}]]></textFieldExpression> </textField> </band> </title> <pageHeader> <band height="35" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="13" splitType="Stretch"/> </columnHeader> <detail> <band height="185" splitType="Stretch"> <stackedBar3DChart> <chart> <reportElement x="57" y="16" width="420" height="165"/> <chartTitle/> <chartSubtitle/> <chartLegend/> </chart> <categoryDataset> <dataset> <datasetRun subDataset="New Dataset 1"> <datasetParameter name="SQL"> <datasetParameterExpression><![CDATA[$P{SQL}]]></datasetParameterExpression> </datasetParameter> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> </datasetRun> </dataset> <categorySeries> <seriesExpression><![CDATA[$F{champ2}]]></seriesExpression> <categoryExpression><![CDATA[$F{champ1}]]></categoryExpression> <valueExpression><![CDATA[$F{nb}]]></valueExpression> </categorySeries> </categoryDataset> <bar3DPlot> <plot/> <itemLabel color="#000000" backgroundColor="#FFFFFF"/> <categoryAxisFormat> <axisFormat> <labelFont/> <tickLabelFont/> </axisFormat> </categoryAxisFormat> <valueAxisFormat> <axisFormat> <labelFont/> <tickLabelFont/> </axisFormat> </valueAxisFormat> </bar3DPlot> </stackedBar3DChart> </band> </detail> <columnFooter> <band height="24" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="20" splitType="Stretch"/> </pageFooter> <summary> <band height="22" splitType="Stretch"/> </summary>
更新 我通过将图表移动到摘要部分解决了问题:)
Update I have solved the problem by moving the chart to the summary part :)
推荐答案在Jasper报告中,您放置在细节带中的所有内容都会重复出现在源中的次数。
In Jasper Report, everything you place in the detail band is repeated number of times it appears in the source.
如果您想只显示一次(不仅是图表),请避开细节带。 例如,您可以将其放在摘要部分。
If you want to show anything (not only chart) just once, avoid the detail band. For example, you can place it in the summary section.
更新:正如其他人指出的那样,我已经扩展了我的答案一点点。
Update: As others pointed, I have extended my answer a little bit.
更多推荐
图表重复多次
发布评论