sashaspb09 Posted April 27, 2021 Share Posted April 27, 2021 I want to add 2 tables in Detail band,they should have 1 data source, i actually did it, but it's filling uncorrect, if it goes on next page.Jasper source<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.13.0.final using JasperReports Library version 6.13.0-46ada4d1be8f3c5985fd0b6146f3ed44caed6f05 --><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="JasperReport_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="7e886936-3be2-4fe0-9174-9eaf030f6bbf"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> <style name="Table_TH" mode="Opaque" backcolor="#FFFFFF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table_CH" mode="Opaque" backcolor="#FFFFFF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table 1_TH" mode="Opaque" backcolor="#FFFFFF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table 1_CH" mode="Opaque" backcolor="#FFFFFF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table 1_TD" mode="Opaque" backcolor="#FFFFFF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <subDataset name="MyCollectionDataSet" uuid="45f9da5c-f860-4e3a-8afb-9ca474b578a2"> <queryString> <![CDATA[]]> </queryString> <field name="id" class="java.lang.Integer"/> <field name="firstName" class="java.lang.String"/> <field name="date" class="java.util.Date"/> <field name="cons" class="java.lang.Double"/> </subDataset> <parameter name="CollectionBeanParam" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/> <parameter name="datesRange" class="java.lang.String"/> <parameter name="countAnaliz" class="java.lang.Integer"/> <queryString> <![CDATA[]]> </queryString> <background> <band splitType="Stretch"/> </background> <title> <band height="101" splitType="Stretch"> <staticText> <reportElement x="0" y="0" width="550" height="30" uuid="d17d317b-e949-49c2-91c3-27168b27d9e7"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="20" isBold="true"/> </textElement> <text><![CDATA[Результаты измерений ВАКХ2000С]]></text> </staticText> <staticText> <reportElement x="0" y="60" width="550" height="30" uuid="7fc85ff9-63ee-4920-a96a-6a97ade6db0a"/> <textElement> <font size="14"/> </textElement> <text><![CDATA[Всего страниц: Всего измерений: ]]></text> </staticText> <textField evaluationTime="Report"> <reportElement x="100" y="60" width="40" height="20" uuid="1bcf9e2f-fee3-496d-b6ee-b13238862864"/> <textElement> <font size="14" isBold="false"/> </textElement> <textFieldExpression> <![CDATA[" " + $V{PAGE_NUMBER}]]> </textFieldExpression> </textField> <textField> <reportElement x="0" y="30" width="550" height="30" uuid="772a0276-cb9e-4b08-8f05-135b3aeeacdf"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14"/> </textElement> <textFieldExpression> <![CDATA[$P{datesRange}]]> </textFieldExpression> </textField> <textField> <reportElement x="490" y="60" width="100" height="30" uuid="9a7dd9b8-e3ee-4975-9a9e-5502ad614d03"/> <textElement> <font size="14"/> </textElement> <textFieldExpression> <![CDATA[$P{countAnaliz}]]> </textFieldExpression> </textField> </band> </title> <detail> <band height="70" splitType="Stretch"> <componentElement> <reportElement x="0" y="0" width="240" height="70" uuid="14d64434-6ac9-49a2-9833-210cf0b508ae"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/> <property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/> <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/> <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/> </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="MyCollectionDataSet" uuid="73069fcb-e6ca-471f-a492-d5e88fed7225"> <dataSourceExpression> <![CDATA[$P{CollectionBeanParam}]]> </dataSourceExpression> </datasetRun> <jr:column width="20" uuid="5b262b0d-7877-4b51-bc45-b4d9964cca80"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/> <jr:columnHeader style="Table_CH" height="20" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="20" height="20" uuid="ac3cb6ae-7e73-468c-89f8-47ea941b7b77"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="10"/> </textElement> <text><![CDATA[№]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="20" height="30" uuid="13532290-2856-4eac-b801-be3fc6b3e563"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="10"/> </textElement> <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="80" uuid="c0c9806f-a637-44ec-808d-88a20e1e390c"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/> <jr:columnHeader style="Table_CH" height="20" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="80" height="20" uuid="1779e3a6-72d0-4507-90e2-81f84b8578ad"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="10"/> </textElement> <text><![CDATA[Дата время]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="80" height="30" uuid="b15db1eb-10cc-433d-abd7-8f97c640cac2"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="10"/> </textElement> <textFieldExpression><![CDATA[$F{date}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="60" uuid="4f40d12b-b5b9-4757-b918-1c08176d0d45"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/> <jr:columnHeader style="Table_CH" height="20" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="60" height="20" uuid="ffb18704-a7c8-4c4d-87bc-5980957c146b"/> <textElement textAlignment="Center" verticalAlignment="Middle" markup="styled"> <font size="10"/> </textElement> <text><![CDATA[С<sub>изм</sub>(мг/дм<sup>3</sup>)]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="60" height="30" uuid="099089c1-21aa-4fb7-94f7-197ac76197a1"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="10"/> </textElement> <textFieldExpression><![CDATA[$F{cons}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="70" uuid="593445a0-4075-43c0-a7cd-93360f622f5d"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/> <jr:columnHeader style="Table_CH" height="20" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="70" height="20" uuid="64988e36-a0e1-4d34-a70e-e501bc807e9f"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="10"/> </textElement> <text><![CDATA[Статус]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="70" height="30" uuid="b764bdc7-29bc-4c0b-93ae-851d107971f3"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="10"/> </textElement> <textFieldExpression> <![CDATA[$F{firstName}]]> </textFieldExpression> </textField> </jr:detailCell> </jr:column> </jr:table> </componentElement> <componentElement> <reportElement x="310" y="0" width="240" height="70" uuid="85d82b74-dc39-4de8-a736-6bde9de71dd7"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/> <property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/> <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/> <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/> </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="MyCollectionDataSet" uuid="20d24f64-7c39-4e71-a401-84f18e66667b"> <dataSourceExpression><![CDATA[$P{CollectionBeanParam}]]></dataSourceExpression> </datasetRun> <jr:column width="20" uuid="3e8b08bc-3b5c-4022-a025-ac6ed8f3150b"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/> <jr:columnHeader style="Table_CH" height="20" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="20" height="20" uuid="afb4ccfc-6adb-4e8b-84d5-3164fd0a279d"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="10"/> </textElement> <text><![CDATA[№]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="20" height="30" uuid="cb056d7e-5234-4379-a7b4-cff0c3336639"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="10"/> </textElement> <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="80" uuid="74d7675e-6b4f-4512-b5c3-1a94eddc5151"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/> <jr:columnHeader style="Table_CH" height="20" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="80" height="20" uuid="5fe41de3-4893-4827-89b6-981806fe4f49"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="10"/> </textElement> <text><![CDATA[Дата время]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="80" height="30" uuid="84ce12be-79ae-44ee-823c-004fb664e4af"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="10"/> </textElement> <textFieldExpression><![CDATA[$F{date}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="60" uuid="77926a9c-aa07-434c-9335-dd93d9002f58"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/> <jr:columnHeader style="Table_CH" height="20" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="60" height="20" uuid="2ddea2f9-b66f-4351-80ec-8a9dbe54c3f3"/> <textElement textAlignment="Center" verticalAlignment="Middle" markup="styled"> <font size="10"/> </textElement> <text><![CDATA[С<sub>изм</sub>(мг/дм<sup>3</sup>)]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="60" height="30" uuid="1bb4cec8-ae9b-4029-9769-f84ba175b9c2"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="10"/> </textElement> <textFieldExpression> <![CDATA[$F{cons}]]> </textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="70" uuid="83f126c6-ab4b-4023-bf42-5a4bb4c15822"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/> <jr:columnHeader style="Table_CH" height="20" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="70" height="20" uuid="d16d12e7-71dd-42a3-82d3-c4eb63af20bc"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="10"/> </textElement> <text><![CDATA[Статус]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="70" height="30" uuid="b0a5155e-afa7-4476-9503-d10952cbecdb"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="10"/> </textElement> <textFieldExpression> <![CDATA[$F{firstName}]]> </textFieldExpression> </textField> </jr:detailCell> </jr:column> </jr:table> </componentElement> </band> </detail> <columnFooter> <band height="80" splitType="Stretch"> <staticText> <reportElement x="380" y="0" width="50" height="30" uuid="7e3df9d1-422b-4b48-9533-590d1822dbaf"/> <textElement> <font size="14"/> </textElement> <text><![CDATA[Дата:]]></text> </staticText> <staticText> <reportElement x="380" y="30" width="130" height="30" uuid="5c2f551e-e263-480d-b897-906ab65487e3"/> <textElement> <font size="14"/> </textElement> <text><![CDATA[Подпись отв. лица:]]></text> </staticText> <textField> <reportElement x="0" y="60" width="80" height="20" uuid="4a75950d-36de-45eb-a19d-191810c0fe5a"/> <textElement textAlignment="Right"> <font size="10" isBold="false"/> </textElement> <textFieldExpression> <![CDATA["Страница "+$V{PAGE_NUMBER}+" из"]]> </textFieldExpression> </textField> <textField evaluationTime="Report"> <reportElement x="80" y="60" width="40" height="20" uuid="2d0b8480-57b8-473a-a424-7b0f7241ee61"/> <textElement> <font size="10" isBold="false"/> </textElement> <textFieldExpression> <![CDATA[" " + $V{PAGE_NUMBER}]]> </textFieldExpression> </textField> <textField pattern="dd.MM.yyyy"> <reportElement x="430" y="0" width="120" height="20" uuid="67bcf485-e8db-48ae-889a-bc658188bb6b"/> <textElement> <font size="14" isBold="false"/> </textElement> <textFieldExpression> <![CDATA[new java.util.Date()]]> </textFieldExpression> </textField> </band> </columnFooter></jasperReport>[/code] Link to comment Share on other sites More sharing options...
jgust Posted April 28, 2021 Share Posted April 28, 2021 The two tables look to be the same. If they are then maybe just one table but two columns? Link to comment Share on other sites More sharing options...
sashaspb09 Posted April 29, 2021 Author Share Posted April 29, 2021 I solved this by adding second dataset for table(also second Parametr with (JRBeanCollectionDataSource) in code i splited my data to 2 datasets,by counting rows ,and adding in left dataset(first 40 id, than id from 80 to 120 ....), or right dataset(from 40 id to 80 id, from 120 to 160 id.....) .... depends on data id Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now