Jasper reports isStartNewColumn=";“真的”;将数据添加到新页面而不是列
我对Jasper Reports和尝试各种功能非常陌生。如果我的理解正确,isStartNewColumn=“true”将为分组字段中的不同数据创建一个新列。但在我的示例中,我看到它在新页面中返回数据 下面是示例jrxmlJasper reports isStartNewColumn=";“真的”;将数据添加到新页面而不是列,jasper-reports,Jasper Reports,我对Jasper Reports和尝试各种功能非常陌生。如果我的理解正确,isStartNewColumn=“true”将为分组字段中的不同数据创建一个新列。但在我的示例中,我看到它在新页面中返回数据 下面是示例jrxml <?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperr
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
name="report2" pageWidth="800" pageHeight="842" columnWidth="700" leftMargin="5" rightMargin="5" language="java"
topMargin="5" bottomMargin="5" uuid="ce08fe1c-1543-4460-8613-7f03b200082b">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="Name" class="java.lang.String" />
<parameter name="type" class="java.lang.String" />
<parameter name="amount" class="java.math.BigDecimal" />
<field name="Name" class="java.lang.String"/>
<field name="type" class="java.lang.String" />
<field name="amount" class="java.math.BigDecimal"/>
<variable name="totalPledge" class="java.math.BigDecimal" resetType="Group" resetGroup="type" calculation="Sum">
<variableExpression><![CDATA[$F{amount}]]></variableExpression>
</variable>
<group name="type" isStartNewColumn="true" >
<groupExpression><![CDATA[$F{type}]]></groupExpression>
<groupHeader>
<band height="61">
<staticText>
<reportElement uuid="87cd0d21-014d-4e6c-a54a-006165a38414" x="0" y="41" width="100" height="20"/>
<textElement/>
<text><![CDATA[Name]]></text>
</staticText>
<staticText>
<reportElement uuid="bd0fc2f5-4963-4c9d-a9be-3659be06e436" x="200" y="41" width="100" height="20"/>
<textElement/>
<text><![CDATA[type]]></text>
</staticText>
<staticText>
<reportElement uuid="5d5d7ce1-5353-4f83-91b4-57725b0c922b" x="100" y="41" width="100" height="20"/>
<textElement/>
<text><![CDATA[amount]]></text>
</staticText>
</band>
</groupHeader>
<groupFooter>
<band height="20">
<textField evaluationTime="Group" evaluationGroup="type">
<reportElement uuid="401c7b3b-af73-4d40-8982-9c1692eb7085" x="100" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$V{totalPledge}]]></textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
<detail>
<band height="20">
<textField>
<reportElement uuid="5b325da6-7c56-4357-8808-911dad16ec53" x="0" y="0" width="100" height="20" isPrintRepeatedValues="false" />
<textElement/>
<textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
</textField>
<textField evaluationTime="Group" evaluationGroup="type">
<reportElement uuid="0bc06b28-7b8c-4af9-997a-714d1599def1" x="200" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{type}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="e5504bb9-c3c0-4135-94c6-7ea935f97cb6" x="100" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{amount}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
下面是数据的代码片段
HashMap<String, Object> fMap1 = new HashMap<String, Object>();
HashMap<String, Object> fMap2 = new HashMap<String, Object>();
fMap1.put("Name", "p2");
fMap1.put("type","credit");
fMap1.put("amount", new BigDecimal(800));
dMap.add(fMap1);
fMap2.put("Name", "p2");
fMap2.put("type","debit");
fMap2.put("amount", new BigDecimal(100));
dMap.add(fMap2);
JRMapCollectionDataSource dataSource = new JRMapCollectionDataSource(dMap);
JasperPrint jprint = JasperFillManager.fillReport(jreport,
params,dataSource);
JasperExportManager.exportReportToPdfFile(jprint,
"src/addCols.pdf");
HashMap fMap1=newhashmap();
HashMap fMap2=新HashMap();
fMap1.put(“名称”、“p2”);
fMap1.put(“类型”、“信用”);
fMap1.投入(“金额”,新的大小数(800));
dMap.add(fMap1);
fMap2.put(“名称”、“p2”);
fMap2.put(“类型”、“借方”);
fMap2.投入(“金额”,新的大小数(100));
dMap.add(fMap2);
JRMapCollectionDataSource=新的JRMapCollectionDataSource(dMap);
JasperPrint jprint=JasperFillManager.fillReport(jreport,
参数(数据源);
JasperExportManager.exportReportToPdfFile(jprint,
“src/addCols.pdf”);
感谢任何关于我可能做错什么的建议。
提前感谢。@Alex K已经添加了标记iReport和Jaspersoft,使用这些工具的人将全面了解jrxml及其属性,并可能有助于查询。谢谢