为什么我使用json文件作为数据源获取空报告? [英] Why I m getting empty report using a json file as datasource?
问题描述
我正在使用tibco jaspersoft studio生成报告
I m using tibco jaspersoft studio to generate a report
在详细信息区域中放置字段将获取所有数据,但是当我尝试使用表时,会得到两个空页面.
droping fields in the detail band is getting all data but when I try to use a table I m getting two empty pages.
打印选项设置为不打印所有部分
the printing option is set to print all sections no details
这是我的数据json文件
here is my data json file
[ {
"clientName" : "SEMMOUD Abderrazak",
"clientPhone" : "043303854",
"codeExterne" : "CLI201801",
"email" : "talcorpdz@gmail.com",
"clientType" : 0,
"clientEtat" : 1,
"identifiant" : "TalcorpDZ",
"contacts" : [ {
"nom" : "Taleb",
"prenom" : "Mohammed Housseyn",
"telephonePortable" : "04330256699",
"email" : null
} ],
"adresses" : [ {
"adress" : "Batiments des enseignants Mohammed Khemisti",
"ville" : "Maghnia"
} ]
}, {
"clientName" : "",
"clientPhone" : "",
"codeExterne" : "sdsqdqs",
"email" : "talcorpdz@gmail.com",
"clientType" : 1,
"clientEtat" : 1,
"identifiant" : "sqdsqd",
"contacts" : [ {
"nom" : "Taleb",
"prenom" : "Mohammed",
"telephonePortable" : "+213778217469",
"email" : null
} ],
"adresses" : [ {
"adress" : "Batiments des enseignants ",
"ville" : "Maghnia"
} ]
} ]
这是我的报告
<?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="refClient" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" whenResourceMissingType="Empty" uuid="758785c8-ae8f-49bd-9995-19c9827a7ebb">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="refcliJsonAdapter"/>
<subDataset name="jsonRefClient" whenResourceMissingType="Empty" uuid="1dcb37f4-96e4-472a-aadb-309de9d05089">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="refcliJsonAdapter"/>
<queryString language="json">
<![CDATA[]]>
</queryString>
<field name="clientName" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="clientName"/>
<fieldDescription><![CDATA[clientName]]></fieldDescription>
</field>
</subDataset>
<queryString language="JSON">
<![CDATA[]]>
</queryString>
<field name="clientName" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="clientName"/>
<fieldDescription><![CDATA[clientName]]></fieldDescription>
</field>
<detail>
<band height="258" splitType="Stretch">
<componentElement>
<reportElement x="40" y="10" width="660" height="200" uuid="a43c33cc-e3f9-470c-8df4-1c36301c869e">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<property name="com.jaspersoft.studio.components.autoresize.proportional" value="true"/>
<property name="com.jaspersoft.studio.components.autoresize.next" value="true"/>
</reportElement>
<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="jsonRefClient" uuid="b4a19c4b-0cb1-481a-a9ba-739ce437135a">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="660" uuid="eda57584-75da-466c-8182-d466356f3cc4">
<jr:tableHeader height="30" rowSpan="1"/>
<jr:tableFooter height="30" rowSpan="1"/>
<jr:columnHeader height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="660" height="30" uuid="d349739f-3e3d-4012-8e52-3b5c7bd75eb9"/>
<text><![CDATA[clientName]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter height="30" rowSpan="1"/>
<jr:detailCell height="30">
<textField>
<reportElement x="0" y="0" width="660" height="30" uuid="fb6bb53f-e520-48f4-81e0-189ae5058656"/>
<textFieldExpression><![CDATA[$F{clientName}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
</jasperReport>
我该怎么做才能解决此问题?
What should I do to fix this issue?
推荐答案
您的表dataSet在运行时实际上未链接到任何数据.快速解决方法是:
Your table dataSet is not actually linked to any data, at runtime. A quick fix is to:
- 将JSON数据适配器导出到与报告相同级别的文件,例如 refcliJsonAdapter.xml
-
将
net.sf.jasperreports.data.adapter
属性添加到表数据集,如下所示:
- Export your JSON Data Adapter to a file on the same level as your report, let's say refcliJsonAdapter.xml
Add the
net.sf.jasperreports.data.adapter
property to your table dataSet, something like:
<subDataset name="jsonRefClient" whenResourceMissingType="Empty" uuid="1dcb37f4-96e4-472a-aadb-309de9d05089">
...
<property name="net.sf.jasperreports.data.adapter" value="refcliJsonAdapter.xml"/>
...
</subDataset>
如果不想重复表,请使用One Empty Record
内置数据适配器预览报告.
Preview the report against the One Empty Record
built-in Data Adapter if you don't want repeating tables.
这篇关于为什么我使用json文件作为数据源获取空报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!