gpt4 book ai didi

java - 贾斯珀报告 : Error creating table trying to use CrossTab without column group

转载 作者:行者123 更新时间:2023-12-01 11:00:50 38 4
gpt4 key购买 nike

我想知道是否有办法制作这样的表格 enter image description here使用JapserReports CrossTab以任何其他方式,其中行组是字段value7

使用的数据集是JRBeanCollectionDataSource( subview 列表)

subview 在哪里:

public class SubView{

//...

private String value1;
private String value2;
private String value3;
private String value4;
private String value5;
private String value6;
private String value7;

//...getters and setters...
}

请注意,不需要列组,但如果我不配置列组,jasper 就无法编译成功(错误消息:Crosstab 应至少有一个列组) .

最佳答案

这对我来说似乎不像 crosstab问题。 Crosstab当列动态时使用,因此您的错误消息

Crosstab should have at least one column group.

因为“不需要列组”,所以结果是使用正常的 detail band 获得的。和groupingvalue7 .

因此,将标签放入 columnHeader 后以及 detail band 中的值 1-6您在 value7 上添加一个分组 groupHeader乐队

示例(我只在 detail band 中包含直到值 3 来对答案进行排序

<?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" printOrder="Horizontal" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isFloatColumnFooter="true" uuid="8944f542-2955-4224-933c-5a87fd36f527">
<queryString>
<![CDATA[]]>
</queryString>
<field name="value1" class="java.lang.String"/>
<field name="value2" class="java.lang.String"/>
<field name="value3" class="java.lang.String"/>
<field name="value7" class="java.lang.String"/>
<group name="Value7">
<groupExpression><![CDATA[$F{value7}]]></groupExpression>
<groupHeader>
<band height="21">
<textField>
<reportElement x="0" y="0" width="300" height="20" uuid="208ca6e5-b396-47cb-858b-71039f5bdf7a"/>
<textFieldExpression><![CDATA["Value 7: " + $F{value7}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
</group>
<background>
<band/>
</background>
<columnHeader>
<band height="50">
<staticText>
<reportElement x="0" y="30" width="100" height="20" uuid="edf0f0f1-c979-4d20-987e-e8decb0b584a"/>
<text><![CDATA[value1]]></text>
</staticText>
<staticText>
<reportElement x="100" y="30" width="100" height="20" uuid="4287323f-e6d3-40d8-a2d4-44981bfa5c59"/>
<text><![CDATA[value2]]></text>
</staticText>
<staticText>
<reportElement x="200" y="30" width="100" height="20" uuid="b9aa7dfd-edd8-439b-b4c7-12916a740da8"/>
<text><![CDATA[value3]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="24">
<textField>
<reportElement x="0" y="0" width="100" height="20" uuid="2bcc436d-4c3a-4db1-a2ea-87edf92af98f"/>
<textFieldExpression><![CDATA[$F{value1}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="100" y="0" width="100" height="20" uuid="f893721e-1aa6-44ca-9a9a-ac795ff63a0a"/>
<textFieldExpression><![CDATA[$F{value2}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="200" y="0" width="100" height="20" uuid="36ad9612-620b-4eec-9608-f26b5306b01a"/>
<textFieldExpression><![CDATA[$F{value3}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>

如果您无论如何都想使用交叉表,则需要以不同的方式设置数据集(因为列也变成动态的)请查看示例:crosstab example

关于java - 贾斯珀报告 : Error creating table trying to use CrossTab without column group,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33344370/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com