Jasper reports JasperReport iReport:JRException: ;错误 ;检索 ;字段 ;值 ;从 ;豆
我试图了解iReport是如何工作的,以及如何创建一个简单的jrxml文件。 报告有标题和标题,数据应在表中。当我尝试使用预览按钮检查报告的外观时,我可以看到标题和标题,但看不到表(请注意,我使用的是我单击了所有字段的“使用默认值”)。当我没有使用默认值时,我得到了这个错误 填充print…net.sf.jasperreports.engine.JRException时出错:从bean:name检索字段值时出错 net.sf.jasperreports.engine.JRRuntimeException:net.sf.jasperreports.engine.jreexception:从bean:name检索字段值时出错 net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:809) net.sf.jasperreports.components.table.fill.FillTableSubreport.prepareSubreport(FillTableSubreport.java:156) net.sf.jasperreports.components.table.fill.FillTable.prepare(FillTable.java:400) net.sf.jasperreports.engine.fill.JRFillComponentElement.prepare(JRFillComponentElement.java:151) 原因:net.sf.jasperreports.engine.JRException:从bean:name检索字段值时出错 位于net.sf.jasperreports.engine.data.jractbeanadasource.getBeanProperty(jractbeanadasource.java:123) 在net.sf.jasperreports.engine.data.jractBeanDataSource.getFieldValue(jractBeanDataSource.java:96) 位于net.sf.jasperreports.engine.data.JRBeanCollectionDataSource.getFieldValue(JRBeanCollectionDataSource.java:109) 原因:java.lang.NoSuchMethodException:类的class java.lang.String上的未知属性“name” 位于org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1322) 位于org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:770) 位于org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:846) 位于org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:426) 位于net.sf.jasperreports.engine.data.jractBeanDataSource.getBeanProperty(jractBeanDataSource.java:111) …还有15份打印件未填写。尝试使用空数据源 我想这个问题可能与我如何为列表输入数据有关。可能格式不对。这就是我键入示例数据的方式 (我的名字,5,马尼拉) (根据屏幕截图,格式正确吗?我甚至尝试将其括在方括号中,但仍然得到相同的错误。) 请注意,我有三栏:姓名、年龄、地址 但在错误消息中,我注意到了这一点Jasper reports JasperReport iReport:JRException: ;错误 ;检索 ;字段 ;值 ;从 ;豆,jasper-reports,Jasper Reports,我试图了解iReport是如何工作的,以及如何创建一个简单的jrxml文件。 报告有标题和标题,数据应在表中。当我尝试使用预览按钮检查报告的外观时,我可以看到标题和标题,但看不到表(请注意,我使用的是我单击了所有字段的“使用默认值”)。当我没有使用默认值时,我得到了这个错误 填充print…net.sf.jasperreports.engine.JRException时出错:从bean:name检索字段值时出错 net.sf.jasperreports.engine.JRRuntimeExcep
Unknown property 'name' on class 'class java.lang.String'
这让我觉得我在创建数据集时做错了什么。(如果我使用了错误的术语,很抱歉)
无论如何,这是iReport生成的xml
<?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="firstReport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="597c0716-df6b-42ec-a7c8-863eb1b7174a">
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#7FFFD4">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFFFEA">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TH" mode="Opaque" backcolor="#7FFFD4">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_CH" mode="Opaque" backcolor="#BFFFEA">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Table Dataset 2" uuid="208e382c-09df-484e-8d2d-a4eb4f4e48ba">
<field name="name" class="java.lang.String"/>
<field name="age" class="java.lang.String"/>
<field name="address" class="java.lang.String"/>
</subDataset>
<parameter name="companyName" class="java.lang.String"/>
<parameter name="date" class="java.util.Date"/>
<parameter name="bean" class="java.util.List"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="32" splitType="Stretch">
<staticText>
<reportElement x="182" y="0" width="184" height="25" uuid="fe64d4b4-efb1-4ed2-ae06-772728fc8b65"/>
<textElement>
<font fontName="Bookman Old Style" size="15" isBold="true"/>
</textElement>
<text><![CDATA[Chart Of Account List]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="58" splitType="Stretch">
<staticText>
<reportElement x="13" y="0" width="100" height="20" uuid="52ae4669-b47e-408c-aabc-e8f470a1d92b"/>
<text><![CDATA[Company]]></text>
</staticText>
<staticText>
<reportElement x="13" y="38" width="100" height="20" uuid="a27fe0e1-9fe6-423f-a006-46c51c7e3e5e"/>
<text><![CDATA[Date Exported]]></text>
</staticText>
<textField>
<reportElement x="113" y="0" width="100" height="20" uuid="1d600fa2-9de4-4999-9222-98a8bcb484f9"/>
<textFieldExpression><![CDATA[$P{companyName}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="113" y="38" width="100" height="20" uuid="1147b818-90ae-4b41-a757-19a590db41d7"/>
<textFieldExpression><![CDATA[$P{date}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<componentElement>
<reportElement key="table 1" style="table 1" x="13" y="0" width="270" height="50" uuid="652523bf-b666-47bc-a1aa-fc20fb9e489a"/>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="Table Dataset 2" uuid="6fcb9950-2d3f-4752-b56d-df7bff1e6991">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{bean})]]></dataSourceExpression>
</datasetRun>
<jr:column width="90" uuid="ee62967c-3669-49fe-a70d-a588ae47439d">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="a0973bfe-815a-498e-8b25-c3320cfe0f62"/>
<text><![CDATA[Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="61d8309e-dd7d-4978-b171-9ae9144e2f5c"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="76a9e313-d134-420e-898b-7f5f444c4efb">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="f79fdf71-a673-4d3a-8e10-b986d99b8e9b"/>
<text><![CDATA[Age]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="e4342bed-af9c-4541-9e57-a24485d0a94d"/>
<textFieldExpression><![CDATA[$F{age}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="5c38c250-d74e-440c-93cb-3fef8ad38157">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="4656a074-f345-483a-971b-b00c95746ec0"/>
<text><![CDATA[Address]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="f2cc3d1c-97ef-48c1-b6e4-a12acc4e67ad"/>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
</jasperReport>
1) 我制作的jrxml有什么问题?我是否向表中提供了格式错误的数据?或者只是我做报告的方式有问题?这是通过在数据源表达式中添加“new”关键字来修复的。通过右键单击报表检查器中的表,您将看到数据源表达式。“编辑表数据源”Hi@peterfrieberg否,该问题已修复,但与数据源有关。我忘记在数据源表达式中添加“new”。非常感谢,你回答了我所有关于iReport的问题。如果没有您的帮助,就无法完成它:)这在jrxml中很奇怪,您有一个新的关键字…new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{bean}),无论如何,您有