How to prevent data from appearing in the report again?

Report Example - Design

My Sample Report - Design

Sample Report - Preview

enter image description here

XML file

<?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="report2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="82a3ce80-bdcd-4d51-8f21-e72b3f438b53"> <style name="table"> <box> <pen lineWidth="1.0" lineColor="#000000"/> </box> </style> <style name="table_TH" mode="Opaque" backcolor="#F0F8FF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="table_CH" mode="Opaque" backcolor="#BFE1FF"> <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> <conditionalStyle> <conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression> <style backcolor="#EFF7FF"/> </conditionalStyle> </style> <style name="table 1"> <box> <pen lineWidth="1.0" lineColor="#000000"/> </box> </style> <style name="table 1_TH" mode="Opaque" backcolor="#F0F8FF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="table 1_CH" mode="Opaque" backcolor="#BFE1FF"> <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> <conditionalStyle> <conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression> <style backcolor="#EFF7FF"/> </conditionalStyle> </style> <subDataset name="dataset1" uuid="70653a81-8d48-4edd-b72f-20f769f51aea"> <queryString language="SQL"> <![CDATA[SELECT schooldetails.`ID` AS schooldetails_ID, schooldetails.`Name` AS schooldetails_Name, schooldetails.`Boardtype` AS schooldetails_Boardtype, schooldetails.`Location` AS schooldetails_Location, schooldetails.`Phone` AS schooldetails_Phone, schooldetails.`Address` AS schooldetails_Address, schooldetails.`Additionaldetails` AS schooldetails_Additionaldetails FROM `schooldetails` schooldetails]]> </queryString> <field name="schooldetails_ID" class="java.lang.Integer"/> <field name="schooldetails_Name" class="java.lang.String"/> <field name="schooldetails_Boardtype" class="java.lang.String"/> <field name="schooldetails_Phone" class="java.lang.String"/> </subDataset> <queryString> <![CDATA[SELECT schooldetails.`ID` AS schooldetails_ID, schooldetails.`Name` AS schooldetails_Name, schooldetails.`Boardtype` AS schooldetails_Boardtype, schooldetails.`Location` AS schooldetails_Location, schooldetails.`Phone` AS schooldetails_Phone, schooldetails.`Address` AS schooldetails_Address, schooldetails.`Additionaldetails` AS schooldetails_Additionaldetails FROM `schooldetails` schooldetails]]> </queryString> <field name="schooldetails_ID" class="java.lang.Integer"/> <field name="schooldetails_Name" class="java.lang.String"/> <field name="schooldetails_Boardtype" class="java.lang.String"/> <field name="schooldetails_Location" class="java.lang.String"/> <field name="schooldetails_Phone" class="java.lang.String"/> <field name="schooldetails_Address" class="java.lang.String"/> <field name="schooldetails_Additionaldetails" class="java.lang.String"/> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"> <staticText> <reportElement uuid="e15d9fdb-5a73-421d-8059-3e6d84742a43" x="0" y="0" width="555" height="79"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="24" isBold="true"/> </textElement> <text><![CDATA[Sample report 2]]></text> </staticText> </band> </title> <detail> <band height="114"> <componentElement> <reportElement uuid="0752ad71-0544-4a92-bc06-666619eada15" key="table 1" style="table 1" x="0" y="0" width="360" height="50"/> <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="dataset1" uuid="46c3a1a8-1e2b-4ea0-b7ac-5b630657c146"> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> </datasetRun> <jr:column width="99" uuid="b4badcbe-8219-4fcf-978c-b5ff6f2057d0"> <jr:columnHeader style="table 1_CH" height="30" rowSpan="1"> <staticText> <reportElement uuid="09f0cb22-b9b2-499a-9e94-0d9edb96e5f8" x="0" y="0" width="99" height="30"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14" isBold="true"/> </textElement> <text><![CDATA[School ID]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="table 1_TD" height="20" rowSpan="1"> <textField> <reportElement uuid="0be272c3-3345-48fd-b90a-a0d0df3bc909" x="0" y="0" width="99" height="20"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <textFieldExpression><![CDATA[$F{schooldetails_ID}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="160" uuid="1f036ef4-d3e4-4113-9084-5530b1e3e8d2"> <jr:columnHeader style="table 1_CH" height="30" rowSpan="1"> <staticText> <reportElement uuid="9ef54b86-c6ac-4f0b-8904-ff82ace55d7c" x="0" y="0" width="160" height="30"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14" isBold="true"/> </textElement> <text><![CDATA[Name]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="table 1_TD" height="20" rowSpan="1"> <textField> <reportElement uuid="6c01ebc8-165d-41da-b632-8b19b67770ac" x="0" y="0" width="160" height="20"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <textFieldExpression><![CDATA[$F{schooldetails_Name}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="114" uuid="7561e583-3af8-4799-ac88-2a7e8c164bfa"> <jr:columnHeader style="table 1_CH" height="30" rowSpan="1"> <staticText> <reportElement uuid="c500ce42-e32d-4704-9832-52d7413926e3" x="0" y="0" width="114" height="30"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14" isBold="true"/> </textElement> <text><![CDATA[Board]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="table 1_TD" height="20" rowSpan="1"> <textField> <reportElement uuid="da078d0e-c6fb-4a3d-a0ed-ea12265cf729" x="0" y="0" width="114" height="20"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <textFieldExpression><![CDATA[$F{schooldetails_Boardtype}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="131" uuid="7842fd3f-e097-4acd-a1ab-a09c0361c23b"> <jr:columnHeader style="table 1_CH" height="30" rowSpan="1"> <staticText> <reportElement uuid="c0519344-d25a-4ed9-8970-1acf9e4857ed" x="0" y="0" width="131" height="30"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14" isBold="true"/> </textElement> <text><![CDATA[Phone]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="table 1_TD" height="20" rowSpan="1"> <textField> <reportElement uuid="560916c9-e02a-40c9-a7af-a63d285b900a" x="0" y="0" width="131" height="20"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <textFieldExpression><![CDATA[$F{schooldetails_Phone}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> </jr:table> </componentElement> </band> </detail> </jasperReport> 

My question

How can I avoid repeating the display of the table twice? I need data to display only once.

As you can see in the above screenshots, I do not want the data to be displayed twice.

+2
source share
3 answers

You have placed your table component in a part group. The detail bar is repeated for each record in the data set. You have two records, so your table is repeated twice; If you had more data, you would get many more repetitions.

You can completely get rid of the table component by placing each columnHeader element from the table in the <columnHeader> range and each detailCell element in the <detail> range. This should preserve the behavior of the table component without repeating it. See http://community.jaspersoft.com/wiki/designing-report for an example.

Alternatively, you can simply move your table component to another group that will not be repeated (e.g. <summary> ).

+2
source

Copy the table component to the summary range and delete the part range.

If you want to repeat the value in the table data, edit your table component in Ireport and select the text box and uncheck the "Print duplicate values" check box in the text box.

XML CODE will look like this: -

  </jr:columnHeader> <jr:detailCell style="table 1_TD" height="20" rowSpan="1"> <textField> <reportElement uuid="560916c9-e02a-40c9-a7af-a63d285b900a" isPrintRepeatedValues="false" x="0" y="0" width="131" height="20"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <textFieldExpression><![CDATA[$F{schooldetails_Phone}]]> </textFieldExpression> </textField> </jr:detailCell> </jr:column> 
+1
source

If your table appears several times in the List component, uncheck the box "Print when the part is full" and try. I like.

0
source

All Articles