我的主报告中有一个子报告。这在细节栏中。问题是它只针对主报告的第一条记录运行。我希望它能为所有细节乐队的唱片播放。它不会显示在其他页面上。为了运行它,我传递了一个sql查询参数,该参数为详细信息带提供信息。
这是jrxml的主报告:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.1.1.final using JasperReports Library version 6.1.1 -->
<!-- 2016-09-26T11:09:48 -->
<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="1350" pageWidth="595" pageHeight="842" whenNoDataType="NoDataSection" columnWidth="511" leftMargin="42" rightMargin="42" topMargin="71" bottomMargin="71" uuid="55ddfd1b-0389-4716-a115-0b6966f4bd05">
<property name="net.sf.jasperreports.export.xml.start.page.index" value="1"/>
<property name="net.sf.jasperreports.export.xml.end.page.index" value="2"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<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="cm"/>
<property name="com.jaspersoft.studio.unit.bottomMargin" value="cm"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="cm"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="cm"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="SQLSRV_SQLDEV"/>
<parameter name="CodCand" class="java.lang.Integer" isForPrompting="false">
<parameterDescription><![CDATA[]]></parameterDescription>
</parameter>
<parameter name="PAGE_INDEX" class="java.lang.Integer" isForPrompting="false">
<defaultValueExpression><![CDATA1]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[ /* QUERY */ ]]>
</queryString>
<field name="Cod_cand" class="java.lang.Integer"/>
<field name="EstadoReg_cand" class="java.lang.Integer"/>
<field name="Nome_cand" class="java.lang.String"/>
<field name="Sigla_idiomaNav" class="java.lang.String"/>
<pageHeader>
<band height="70" splitType="Stretch">
<image>
<reportElement x="0" y="0" width="110" height="50" uuid="db7d5ce0-2740-4b4a-b84e-d4aacac33ced"/>
<imageExpression><![CDATA["/home/diego.queres/Desenv/Relatórios Clientes/MyReports/Cafe com leite.JPG"]]></imageExpression>
</image>
</band>
</pageHeader>
<detail>
<band height="563" splitType="Stretch">
<textField>
<reportElement x="0" y="10" width="260" height="30" uuid="ff0bc8d6-87d0-4fba-84fe-b3def51ac8f1"/>
<textElement>
<font fontName="Arial" size="18"/>
</textElement>
<textFieldExpression><![CDATA[$F{Nome_cand}]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="Float" x="100" y="60" width="160" height="30" uuid="dd77bdb7-560b-4054-88ea-2b14f5032b06"/>
<textFieldExpression><![CDATA[$F{Sigla_idiomaNav}]]></textFieldExpression>
</textField>
<staticText>
<reportElement positionType="Float" x="0" y="60" width="100" height="30" uuid="2a0e78b4-1fc0-428d-95fa-86c7f8e669a0"/>
<text><![CDATA[Idioma candidato]]></text>
</staticText>
<textField isStretchWithOverflow="true">
<reportElement positionType="Float" x="100" y="90" width="410" height="40" uuid="54e06bcd-be90-48ca-b861-78b39f55681c"/>
<textFieldExpression><![CDATA[$F{EstadoReg_cand} + "\n" +
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. In pretium quam non odio cursus viverra. Integer dolor sapien, suscipit quis placerat eget, tincidunt at ipsum. Morbi molestie sit amet tellus non commodo. Donec vel arcu lobortis, bibendum metus vitae, varius leo. Maecenas ultrices nisi id sapien volutpat viverra. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed eget erat non felis tempus sodales in id quam. Proin suscipit porta faucibus. Etiam vitae elit facilisis, pulvinar ipsum at, facilisis ante. Nulla ac mauris erat. Curabitur sit amet metus id metus cursus lacinia eget ut orci. Nullam ornare erat nulla, pretium viverra justo hendrerit ac. Interdum et malesuada fames ac ante ipsum primis in faucibus. Praesent sed nisl risus. Nulla facilisi." +
"\n" +
"Curabitur sodales finibus arcu at condimentum. Integer at tempor mi, eu euismod dolor. Nulla facilisi. Suspendisse potenti. Nullam feugiat turpis condimentum turpis tempor sagittis. Pellentesque accumsan elementum auctor. Mauris orci dui, convallis id sagittis a, dapibus eget dui. Vivamus sit amet ante id elit malesuada porta non eget dui. Nulla nisi sem, dictum at metus eu, facilisis ornare neque. Pellentesque in lectus vel libero laoreet faucibus vel non odio. Aenean euismod neque eu nisl rutrum fringilla. In nibh enim, sollicitudin ut aliquet sit amet, pulvinar sit amet odio. Duis fringilla, odio eget fermentum eleifend, urna sem volutpat diam, at dictum elit turpis ut mauris. Vivamus rutrum turpis ut ex sodales vulputate." +
"\n" +
"Curabitur laoreet ligula et augue tincidunt pharetra. Fusce finibus non tellus in sollicitudin. Aliquam quis venenatis tellus. Quisque leo erat, rutrum nec ex a, dictum interdum augue. In et tincidunt diam. Sed sagittis nibh id ex laoreet hendrerit. Aliquam non nunc odio. Nam dolor diam, eleifend sit amet enim vel, laoreet tincidunt nibh. Etiam vitae elementum mi. Ut ornare a sapien sit amet congue." +
"\n" +
"Maecenas tempor cursus mauris. Mauris vehicula pharetra scelerisque. Maecenas feugiat justo purus, vel fermentum odio venenatis eu. Aliquam quis libero maximus, convallis odio a, eleifend nisi. Phasellus placerat, nulla ut rutrum sagittis, magna turpis tincidunt nisl, vel mollis libero massa ut arcu. Donec et tincidunt sem, ut pellentesque arcu. Sed laoreet ornare gravida. Nunc mauris mauris, elementum sit amet porttitor vel, feugiat ut sem. Donec ultrices quam mollis blandit facilisis. Morbi mollis semper enim, nec lobortis nisl blandit at. Ut leo magna, maximus ullamcorper finibus et, bibendum ut eros." +
"\n" +
"Nam eros risus, lacinia semper augue sed, interdum dapibus turpis. Mauris placerat iaculis fringilla. Vestibulum ullamcorper nibh et tortor ullamcorper accumsan. In ipsum eros, consectetur non blandit non, eleifend id elit. Suspendisse non bibendum mi. Suspendisse finibus eleifend mauris. Integer rutrum, ex vitae suscipit luctus, sapien erat tincidunt dui, sit amet ultricies magna sem at ligula. Fusce dictum, dolor sed commodo rutrum, eros quam eleifend libero, nec aliquam libero risus vitae ipsum. Vivamus nec libero metus. Mauris volutpat sapien vitae tortor tincidunt semper. Integer aliquet purus a urna dictum, id vehicula ante convallis. Suspendisse dolor velit, volutpat ut mi non, faucibus lobortis nulla. Quisque sed nisi nunc."]]></textFieldExpression>
</textField>
<staticText>
<reportElement positionType="Float" stretchType="RelativeToBandHeight" x="0" y="90" width="100" height="40" uuid="2452709f-be5e-4c5a-bece-c54a03e532f7"/>
<text><![CDATA[EstadoReg_cand]]></text>
</staticText>
<break>
<reportElement x="0" y="550" width="509" height="1" uuid="cfd93607-c001-4860-8fe5-848979c466ce"/>
</break>
<subreport>
<reportElement positionType="Float" x="100" y="130" width="409" height="70" uuid="e3dea3c0-56e8-42c8-b35c-d74b42d79858"/>
<subreportParameter name="CodCand">
<subreportParameterExpression><![CDATA[$F{Cod_cand}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["/home/diego.queres/Desenv/Relatórios Clientes/MyReports/1350-formacoes.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<pageFooter>
<band height="66" splitType="Stretch">
<textField>
<reportElement x="409" y="36" width="100" height="30" uuid="422e0e4d-35f2-42eb-bfe1-c805991fd470"/>
<textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
</jasperReport>
子报表 jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.1.1.final using JasperReports Library version 6.1.1 -->
<!-- 2016-09-27T10:20:16 -->
<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="1350-formacoes" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a9eac827-ef0f-401c-80eb-8cf6417e4906">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="SQLSRV_SQLDEV"/>
<parameter name="CodCand" class="java.lang.String"/>
<queryString>
<![CDATA[select * from [dbo].[candform] where codcand = $P{CodCand} ]]>
</queryString>
<field name="CodCand_form" class="java.lang.Integer"/>
<field name="Descr_form" class="java.lang.String"/>
<field name="Instit_form" class="java.lang.String"/>
<field name="Pais_form" class="java.lang.String"/>
<field name="Estado_form" class="java.lang.String"/>
<field name="TipoCurso_form" class="java.lang.String"/>
<field name="Descr_cursoGrad" class="java.lang.String"/>
<field name="Descr_cursoPGrad" class="java.lang.String"/>
<field name="Duracao_form" class="java.lang.String"/>
<field name="dataStatus_form2" class="java.lang.String"/>
<field name="dataStatus_form3" class="java.lang.String"/>
<field name="dataStatus_form" class="java.sql.Timestamp"/>
<field name="Situacao_form" class="java.lang.String"/>
<field name="cod_form" class="java.lang.Integer"/>
<field name="cod_formresumido" class="java.lang.Integer"/>
<field name="Nivel" class="java.lang.String"/>
<field name="Area_form" class="java.lang.String"/>
<field name="RowNumber_form" class="java.lang.Integer"/>
<field name="RowNumber_codform" class="java.lang.Integer"/>
<detail>
<band height="70">
<textField>
<reportElement x="120" y="10" width="450" height="30" uuid="41091178-6353-4264-81ff-07919aaeb4dd"/>
<textFieldExpression><![CDATA[$F{Descr_form}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="20" y="10" width="100" height="30" uuid="73c9de13-3e0b-4c65-a9b3-628f419c8efc"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Descr_form]]></text>
</staticText>
<textField>
<reportElement x="120" y="40" width="450" height="30" uuid="ec4daab6-894e-4d8c-9823-a33d5acafa38"/>
<textFieldExpression><![CDATA[$F{Instit_form}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="20" y="40" width="100" height="30" uuid="5408a543-a168-437d-89ef-1ab6671a1b38"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Instit_form]]></text>
</staticText>
</band>
</detail>
</jasperReport>
您的报告有几个问题:
queryString
生成的记录数)。这可能是您在文本字段之后什么也看不到的原因。要对此进行测试,可以手动检查您的SQL查询,或者在子报告中设置:无数据类型时:无数据部分
并添加一个noData
带(从JaspersoftStudio的Outline视图中)和一个您选择的staticText
。当子报表的mainDataset为空时,这将仅触发noData
波段的呈现。这样,当没有可显示的内容时,您可以拥有某种占位符。
是否有任何缓存或某种设置在jasper或类似的东西?
我正在尝试使用带有子报表的主报表,而这个也带有子报表。我有一个Object列表,我将其作为JAVA的参数传递。当我打印Jasper时,只打印列表中的第一项,我不知道为什么(如果我只使用Master和一个子报表,它将打印所有对象并正确显示所有数据)。 代码是:JAVA(最相关的部分) JRXML大师 子报告 子子报表 请忽略jrxml的简单设计,我只是删除了不相关的信息。知道吗?
当我在没有图表的情况下使用JasperReports创建报表时,Java应用程序并从jbutton调用它 我很累地寻找如何解决这个问题,但在网上什么也没找到
编辑:代码如下。
在主报表的细节部分,我创建了两个非常相同的子报表。我在主报表上指定了这两个子报表的高度为300像素,因此它们占据相等的空间,并在设计中一个接一个地显示为两个框。 子报表的设计如下所示。它的高度保持在300px。详细信息带根据从数据库返回的行数进行迭代。这可能返回3到8行。 现在,我希望在预览子报表时,如下图所示逐个显示子报表,其间没有任何空白。现在,当第一行只返回3行时,我看到它们之间有空白。如何
我目前的技能只能通过使用JRBeanCollectionDataSource(list)作为数据源,在不使用子报表的情况下制作pdf。(数据打印成功) 谁能告诉我如何制作包含多个子报表的pdf报表,主jrxml文件和子报表jrxml文件中应该包含哪些内容,以及java代码中应该包含哪些内容?以及如何使用多个JRBeanCollectionDataSource(列表)?我唯一知道的是使用Map pa