Jump to content
Changes to the Jaspersoft community edition download ×

Use a correct layout


raffa74

Recommended Posts

Hi, i have this problem:

suppose to use this file xml like datasoruce:


<RECORD>
   <DATA>
       <COD>COD01 </COD>
       <DESC1>RITIRO E SMALTIMENTO RIFIUTI</DESC1>
       <DESC2>SPECIALI (XXX) FFFFF</DESC2>
       <DESC3>DESCRIZIONE 3</DESC3>
       <DESC4>DESCRIZIONE 4</DESC4>
       <DESC5>DESCRIZIONE 5</DESC5>
       <DESC6>DESCRIZIONE 6</DESC6>
   </DATA>
   <DATA>
       <COD>COD02 </COD>
       <DESC1>SMALTIMENTO VS RIFIUTI COD.</DESC1>
       <DESC2>MAG. 51900 CER 150106</DESC2>    
       <DESC3>DESCRIZIONE 3</DESC3>
       <DESC4>DESCRIZIONE 4</DESC4>
       <DESC5>DESCRIZIONE 5</DESC5>
       <DESC6>DESCRIZIONE 6</DESC6>
   </DATA>
   <DATA
       <COD>COD03 </COD>
       <DESC1>SMONTAGGIO, RIMOZIONE E BONI-</DESC1>
   </DATA>
   <DATA
       <COD>COD04</COD>
       <DESC1>DES1. CONT.10 LT.</DESC1>
       <DESC2>DES2. CONT.10 LT.</DESC2>         
       <DESC3>DESCRIZIONE 3</DESC3>
       <DESC4>DESCRIZIONE 4</DESC4>
       <DESC5>DESCRIZIONE 5</DESC5>
       <DESC6>DESCRIZIONE 6</DESC6>
   </DATA>
 </RECORD>

******************

Data is the node and like you see not every field have value, therefore i've set for every field the option remove when empty.

Suppose to print for every page only 16 row of detail band.

The report Print in the page 1 the record 1 and 2 (code01+code02) while record 3 (code03) in the page 3 having only 2 records!!!

I want in the first page code01(7 field)+code02(7 field)+code03(2 field) and in the second page the cod04(7 field).

Can you help me? I hope you understand what i mean..

 

Ciao

 

Link to comment
Share on other sites

  • 2 months later...
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Ok, here is the main report:

<?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="aa057719-243a-418b-b3ea-8ed5cc10621e">
 <property name="ireport.zoom" value="1.0"/>
 <property name="ireport.x" value="0"/>
 <property name="ireport.y" value="0"/>
 <property name="net.sf.jasperreports.export.xls.remove.empty.space.between.rows" value="true"/>
 <queryString language="xPath">
  <![CDATA[/recordset/testa]]>
 </queryString>
 <field name="chiave" class="java.lang.String">
  <fieldDescription><![CDATA[chiave]]></fieldDescription>
 </field>
 <field name="rag2" class="java.lang.String">
  <fieldDescription><![CDATA[rag2]]></fieldDescription>
 </field>
 <field name="rag1" class="java.lang.String">
  <fieldDescription><![CDATA[rag1]]></fieldDescription>
 </field>
 <background>
  <band splitType="Stretch"/>
 </background>
 <pageHeader>
  <band height="134" splitType="Stretch">
   <rectangle>
    <reportElement uuid="898264a0-e274-4153-8c8a-ff1c4bb8d132" x="0" y="0" width="551" height="134" backcolor="#FFCCCC"/>
   </rectangle>
   <staticText>
    <reportElement uuid="e36f71f7-92dd-4663-92ab-2256abd35759" x="91" y="56" width="351" height="40"/>
    <textElement textAlignment="Center">
     <font size="24" isBold="true"/>
    </textElement>
    <text><![CDATA[TITOLO]]></text>
   </staticText>
  </band>
 </pageHeader>
 <detail>
  <band height="120" splitType="Stretch">
   <subreport>
    <reportElement uuid="61d24c97-269a-43ce-909d-64f562d80608" x="0" y="1" width="555" height="38" isRemoveLineWhenBlank="true"/>
    <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("testa/corpo")]]></dataSourceExpression>
    <subreportExpression><![CDATA["C:\Users\Raffaele\Desktop\Raffa\IReport\Prova\Report\report1_subreport1.jasper"]]></subreportExpression>
   </subreport>
  </band>
 </detail>
 <pageFooter>
  <band height="128" splitType="Stretch">
   <rectangle>
    <reportElement uuid="568f3530-43a8-4cfe-a01d-af50cae21fd7" x="0" y="-81" width="551" height="209" backcolor="#FFCCCC"/>
   </rectangle>
   <staticText>
    <reportElement uuid="4036cf16-18ff-4d54-bb46-0bced7b9617b" x="91" y="14" width="351" height="40"/>
    <textElement textAlignment="Center">
     <font size="24" isBold="true"/>
    </textElement>
    <text><![CDATA[PIE' DI PAGINA]]></text>
   </staticText>
  </band>
 </pageFooter>
</jasperReport>

..............................................
..............and the 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_subreport1" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="c7a7b033-96e4-4cdd-8240-fc48443eb1a1">
 <property name="ireport.zoom" value="1.0"/>
 <property name="ireport.x" value="0"/>
 <property name="ireport.y" value="0"/>
 <property name="net.sf.jasperreports.export.xls.remove.empty.space.between.rows" value="TRUE"/>
 <queryString language="xPath">
  <![CDATA[/recordset/testa/corpo]]>
 </queryString>
 <field name="codice" class="java.lang.String">
  <fieldDescription><![CDATA[codice]]></fieldDescription>
 </field>
 <field name="desc" class="java.lang.String">
  <fieldDescription><![CDATA[desc]]></fieldDescription>
 </field>
 <field name="desc1" class="java.lang.String">
  <fieldDescription><![CDATA[desc1]]></fieldDescription>
 </field>
 <field name="desc2" class="java.lang.String">
  <fieldDescription><![CDATA[desc2]]></fieldDescription>
 </field>
 <field name="desc3" class="java.lang.String">
  <fieldDescription><![CDATA[desc3]]></fieldDescription>
 </field>
 <field name="desc4" class="java.lang.String">
  <fieldDescription><![CDATA[desc4]]></fieldDescription>
 </field>
 <field name="desc5" class="java.lang.String">
  <fieldDescription><![CDATA[desc5]]></fieldDescription>
 </field>
 <field name="desc6" class="java.lang.String">
  <fieldDescription><![CDATA[desc6]]></fieldDescription>
 </field>
 <field name="desc7" class="java.lang.String">
  <fieldDescription><![CDATA[desc7]]></fieldDescription>
 </field>
 <detail>
  <band height="140" splitType="Stretch">
   <textField>
    <reportElement uuid="cbf2e121-e233-482d-b4f5-eb3ecbe168cf" x="5" y="0" width="69" height="20"/>
    <textElement/>
    <textFieldExpression><![CDATA[$F{codice}]]></textFieldExpression>
   </textField>
   <textField>
    <reportElement uuid="4df6d21c-7a96-4bc6-86b5-7eaa2b3bc01e" x="83" y="0" width="206" height="20"/>
    <textElement/>
    <textFieldExpression><![CDATA[$F{desc}]]></textFieldExpression>
   </textField>
   <textField isBlankWhenNull="true">
    <reportElement uuid="c43919dc-d256-4d5c-a551-5d3a9db8f5e7" x="83" y="20" width="206" height="20" isRemoveLineWhenBlank="true"/>
    <textElement/>
    <textFieldExpression><![CDATA[$F{desc1}]]></textFieldExpression>
   </textField>
   <textField isBlankWhenNull="true">
    <reportElement uuid="896523f9-a961-4563-88bc-68f2a2ae10d0" x="83" y="40" width="206" height="20" isRemoveLineWhenBlank="true"/>
    <textElement/>
    <textFieldExpression><![CDATA[$F{desc2}]]></textFieldExpression>
   </textField>
   <textField isBlankWhenNull="true">
    <reportElement uuid="d75a1a85-8294-4c80-9ee1-2873c139c255" x="83" y="60" width="206" height="20" isRemoveLineWhenBlank="true"/>
    <textElement/>
    <textFieldExpression><![CDATA[$F{desc3}]]></textFieldExpression>
   </textField>
   <textField isBlankWhenNull="true">
    <reportElement uuid="e1001800-e91c-4c5d-9823-8bd4c9813bbd" x="83" y="80" width="206" height="20" isRemoveLineWhenBlank="true"/>
    <textElement/>
    <textFieldExpression><![CDATA[$F{desc4}]]></textFieldExpression>
   </textField>
   <textField isBlankWhenNull="true">
    <reportElement uuid="4093cdc5-d7d4-4619-8d15-eaf815176069" x="83" y="100" width="206" height="20" isRemoveLineWhenBlank="true"/>
    <textElement/>
    <textFieldExpression><![CDATA[$F{desc5}]]></textFieldExpression>
   </textField>
   <textField isBlankWhenNull="true">
    <reportElement uuid="30fd7c4d-ec2d-4b1d-bbcf-6f90889e777b" mode="Transparent" x="83" y="120" width="206" height="20" isRemoveLineWhenBlank="true" backcolor="#FFFFCC"/>
    <textElement/>
    <textFieldExpression><![CDATA[$F{desc6}]]></textFieldExpression>
   </textField>
  </band>
 </detail>
</jasperReport>

**************************************

thank you for your help

 

 

 

Link to comment
Share on other sites

I loaded your JRXMLs but without the XMLs as DataSources it's hard to reproduce... additionally it's not really clear for me, why you put the PageFooterr Content into negative TopValue of -81 pixel??? That's not a good idea because it could overlap the data of the growing detailband!??!?!

So as you designed with an SubReport and I assume, you want to use the WHOLE space that could be filled for a page.. try this:

1.) don't use such a huge detailband on masterReport of 120pixel... you could decrease it (and also the SubReportElement) to a height of 13pixel (= 1 Row of text when using SansSerif 10 pt) -> (actually you could also set all of your SubReport-Fields to a height of 13pixel as SansSerif 10pt don't need 20 Pixel! But perhaps you need such a large distance between the fields!?!?)

2.) set the detailband in SubReport to SplitType "prevent" to be sure, that one (sub)record won't split over two pages! (I assume this is what you need?)

3.) decrease the pagefooter in MasterReport... you have 140pixel defined for SubReport... if you want 4 records displayed at one page you will need 560 pixel (4x140) totally wihin the Master detail.. but your huge PageFooter is just 20 pixel to large so that finally just 540 Pixel are left for your records... and so the engine will break.

I do attach your files .... just run it with an empty datasource (1 record) for master... the SubReport is called with JREmptyDataSource(4) and you will see, that all 4 records will fit at first page. (you will need to set the SubReportExpression path back to your filesystem of course)

 

hth + regards from Germany

C-Box

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...