我试图使用report(report1_subreport3.jrxml)设计器从主report(report1.jrxml)中创建一个子iReport (两者都带有空数据源)。主报表详细带包含静态文本(“主报表”),子报表元素和子报表在相应的详细带(“subreport”)中包含静态文本。
但单击主报表的预览选项卡仅显示静态文本“主报表”,而不显示子报表(“subreport”)的静态文本。
我还浏览了链接http://community.jaspersoft.com/questions/524978/empty-subreport-xml-datasource-ireport,但仍然面临着这个问题。
下面是report1.jrxml
<?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="report1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="20036b98-ef64-4dea-8345-b89bcd8f2671">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="68"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["D:\\soapReport\\jasperReport\\"]]></defaultValueExpression>
</parameter>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<staticText>
<reportElement uuid="d49ee6bf-1a13-41bb-9feb-f0fb2ec414f2" x="71" y="28" width="100" height="20"/>
<textElement/>
<text><![CDATA[Main Report]]></text>
</staticText>
<subreport>
<reportElement uuid="364d3c38-a0a1-4fa5-b0bf-12b22314ac5e" x="311" y="14" width="200" height="100"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "report1_subreport3.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
下面是report1_subreport3.jrxml
<?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="report1_subreport3" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="7ca2d973-972c-4c56-8d5e-503b32b4afc6">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<staticText>
<reportElement uuid="5f488fe4-f9f7-4f12-9c1e-812661026bd7" x="222" y="50" width="100" height="20"/>
<textElement/>
<text><![CDATA[Sub Report]]></text>
</staticText>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
谢谢你在这方面的帮助.
谢谢Gopi的更改,但是仍然在 subreport的位置上显示空白。下面的是的主要报告
<?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="report1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="748f862c-3467-4c8c-89f6-04a571192482">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["D:/soapReport/jasperReport/"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="71" splitType="Stretch">
<staticText>
<reportElement uuid="17f2cfc8-497a-4676-b83a-acf55bccac04" x="33" y="15" width="100" height="20"/>
<textElement/>
<text><![CDATA[Main Report]]></text>
</staticText>
</band>
</detail>
<columnFooter>
<band height="134" splitType="Stretch">
<subreport>
<reportElement uuid="40f53bea-c9eb-46a7-b4fc-3d592da3ef90" x="234" y="17" width="200" height="100"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["D:/soapReport/jasperReport/report1_subreport1.jasper"]]></subreportExpression>
</subreport>
</band>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
及以下是子报表
<?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="report1_subreport1" language="groovy" pageWidth="555" pageHeight="802" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="62bf7fb7-8145-4aa6-b963-c98eefac9862">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<background>
<band splitType="Stretch"/>
</background>
<columnHeader>
<band height="61" splitType="Stretch">
<staticText>
<reportElement uuid="9bf9eafc-c1e0-49fa-8bb8-ed6c496498da" x="213" y="20" width="100" height="20"/>
<textElement/>
<text><![CDATA[Sub Report]]></text>
</staticText>
</band>
</columnHeader>
</jasperReport>
如果我错过了什么. PLease帮我.
发布于 2012-11-08 11:34:58
将您的子报表字段放置在除详细信息以外的任何其他带中,并将whenNoDataType="AllSectionsNoDetail"
添加到您的xml文件中。
将其添加到<JasperReport>
标记中的其他报表属性中。
还可以使用GUI设计器进行添加。
打开您的子报表,在属性编辑器中,在您将找到的选项的末尾。
When No Data
选项从可用选项列表中选择All Sections with No Detail
。
报告:
<?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="report1" 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="12"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["/home/qualian/Desktop/gopi/prjreport/"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<subreport>
<reportElement x="33" y="56" width="208" height="36"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR}+"report3_subreport1.jasper"]]></subreportExpression>
</subreport>
<staticText>
<reportElement x="33" y="15" width="100" height="20"/>
<textElement/>
<text><![CDATA[Main Report]]></text>
</staticText>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
小组报告:
<?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="report1_subreport3" language="groovy" pageWidth="555" pageHeight="802" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<background>
<band splitType="Stretch"/>
</background>
<columnHeader>
<band height="40" splitType="Stretch">
<staticText>
<reportElement x="107" y="12" width="100" height="20"/>
<textElement/>
<text><![CDATA[Sub Report]]></text>
</staticText>
</band>
</columnHeader>
这就像一种魅力。希望这能有所帮助。
发布于 2016-12-15 15:38:21
上面的问题是用下面的标签解决的,我已经把它包括在我的主要报告中了。我们需要使用空数据源(新的net.sf.jasperreports.engine.JREmptyDataSource()) )
SUBREPORT.jrxml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 -->
<!-- 2016-12-15T10:33:58 -->
<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="HYPERLINKS_SUBREPORT" pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="ad9606b1-969d-4340-a7eb-61dc30ec8f0d">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<queryString>
<![CDATA[]]>
</queryString>
<detail>
<band height="82" splitType="Stretch">
<staticText>
<reportElement x="16" y="47" width="100" height="30" uuid="866e60e7-16a0-4fea-b56f-ca4143e98fec"/>
<text><![CDATA[Testing text]]></text>
</staticText>
</band>
</detail>
main_report.jrxml的XML
<subreport>
<reportElement positionType="Float" x="0" y="220" width="200" height="60" uuid="62463158-73b1-4089-b66c-633d3a987649"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
<subreportExpression><![CDATA["SUBREPORT.jasper"]]></subreportExpression>
</subreport>
同样可以使用Jaspersoft Studio.实现。
发布于 2016-07-08 15:41:29
任何没有显示子报表的jasper reports studio 6.3.0有问题的人都应该尝试更改子报告中参数的名称,然后更新主reports子报表小部件“编辑参数”选项中的参数连接,以匹配新的参数名。也可以避免下划线。"USER_ID“。
https://stackoverflow.com/questions/13287302
复制相似问题