bookworm Posted February 10, 2012 Share Posted February 10, 2012 when dragged into the detail band, the tables are getting printed repeatedly..if placed in the summary band, it is getting printed only once but on the last page..empty pages are getting printed before it..am i doing something wrong?please help.. P.S.have attached the jrxml code for referral..Code:<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version last--><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="Blank A4" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="trial"/> <subDataset name="Dataset1"> <queryString language="SQL"> <![CDATA[select * from emp]]> </queryString> <field name="empid" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="empname" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="emp_age" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> </subDataset> <queryString language="SQL"> <![CDATA[select * from emp]]> </queryString> <field name="empid" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="empname" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="emp_age" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"/> </title> <pageHeader> <band height="35" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="34" splitType="Stretch"/> </columnHeader> <detail> <band height="72" splitType="Stretch"/> </detail> <columnFooter> <band height="75" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="6" splitType="Stretch"/> </pageFooter> <summary> <band height="42" splitType="Stretch"> <componentElement> <reportElement x="120" y="7" width="200" height="28"/> <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"> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> </datasetRun> <jr:column width="40"> <jr:columnHeader height="40"> <staticText> <reportElement x="0" y="0" width="40" height="40"/> <textElement/> <text><![CDATA[empid]]></text> </staticText> </jr:columnHeader> <jr:detailCell height="40"> <textField> <reportElement x="0" y="0" width="40" height="40"/> <textElement/> <textFieldExpression><![CDATA[$F{empid}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="40"> <jr:columnHeader height="40"> <staticText> <reportElement x="0" y="0" width="40" height="40"/> <textElement/> <text><![CDATA[empname]]></text> </staticText> </jr:columnHeader> <jr:detailCell height="40"> <textField> <reportElement x="0" y="0" width="40" height="40"/> <textElement/> <textFieldExpression><![CDATA[$F{empname}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="40"> <jr:columnHeader height="40"> <staticText> <reportElement x="0" y="0" width="40" height="40"/> <textElement/> <text><![CDATA[emp_age]]></text> </staticText> </jr:columnHeader> <jr:detailCell height="40"> <textField> <reportElement x="0" y="0" width="40" height="40"/> <textElement/> <textFieldExpression><![CDATA[$F{emp_age}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> </jr:table> </componentElement> </band> </summary></jasperReport> Link to comment Share on other sites More sharing options...
cbarlow3 Posted February 10, 2012 Share Posted February 10, 2012 I confess that I didn't actually read the code, but if your table, chart, etc. summarizes the information across multiple detail records, then you want that table/chart/whatever in a summary that follows the detail. That might be the summary band or it could be a group footer band, for example. Not only did you see the table "repeated" (appearing multiple times) when you put it in the detail band, but I suspect that the data in that table was changing with each detail, until finally you had one that represented the total information with the last detail. So you did the right thing creating in the summary band instead.Next problem: the blank pages. I suspect this is happening because you still have a detail band defined but have nothing displayed in that detail band. Your obvious choices are to either (a) drag some detail information into the detail band so you have pages of data leading up to a summary table, or (b) delete the detail band (right click on it in the tree and select "Delete band"--you can always change your mind later and create an empty one again) so you have just the Title and Summary bands and don't have a detail band (blank or otherwise) that prints for every row returned from your query. The thing that tricks people at the beginning (particularly if their first report is a summary, not detail) is that even though the design area makes it look like the detail band is a single row on a report, it's actually just the design for a row that will be repeated for every result row from your query.Hope that helps.CarlPost Edited by cbarlow3 at 02/10/2012 18:00 Link to comment Share on other sites More sharing options...
bookworm Posted February 13, 2012 Author Share Posted February 13, 2012 Thanks a lot cbarlow3!It works after deleting the detail band .:) Post Edited by bookworm at 02/13/2012 04:54 Link to comment Share on other sites More sharing options...
ganeshkamath89 Posted July 18, 2016 Share Posted July 18, 2016 In my report, I used to have 2 separate detail section for the 2 subreports I was using. This was causing both sub-reports to show twice. To solve this problem, I moved both sub-reports to the same details section and started using only 1 details section. 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