Jump to content
JasperReports Library 7.0 is now available ×

Invalid summary values in table


alena.cepkova

Recommended Posts

Hi, I have table in my report contains text and numeric value, text should change column size according to it's length. I have summary of all previous values in column header and column footer on every page. That means sum in column footer should be the same as sum in next page column header, but it Isn't. On next page there is added value from first line of table to sum in column header above. Sometimes it works, sometimes it doesn't depending on the text length.

My template looks like bellow. I also attached the PDF example.

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.17.0.final using JasperReports Library version 6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd  --><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="new" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="jasper.localization.i18n" uuid="56cb3807-76eb-477a-ba3d-b1dcfcf40014">   <property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/>   <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">      <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="#BFE1FF">      <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>   <subDataset name="ShopItemDataset" uuid="ee7c3d5a-e1db-4b25-a911-119a3e7a006a">      <parameter name="shopItem" class="Com.example.model.ShopItem">         <defaultValueExpression><![CDATA[$P{order}]]></defaultValueExpression>      </parameter>      <queryString>         <![CDATA[]]>      </queryString>      <field name="description" class="java.lang.String"/>      <field name="price" class="java.math.BigDecimal"/>      <variable name="total" class="java.math.BigDecimal" calculation="Sum">         <variableExpression><![CDATA[$F{price}]]></variableExpression>      </variable>   </subDataset>   <parameter name="invoiceData" class="de.eurodata.edorga.invoicedocumentfactory.pdfgeneration.model.InvoiceDataModel"/>   <queryString>      <![CDATA[]]>   </queryString>   <background>      <band splitType="Stretch"/>   </background>   <title>      <band height="79" splitType="Stretch"/>   </title>   <pageHeader>      <band height="93" splitType="Stretch"/>   </pageHeader>   <columnHeader>      <band height="61" splitType="Stretch"/>   </columnHeader>   <detail>      <band height="250" splitType="Stretch">         <componentElement>            <reportElement x="74" y="50" width="200" height="200" uuid="b0913be8-f333-44ac-95b6-fe727b5c288b">               <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="ShopItemDataset" uuid="b899f322-1b69-415d-a28c-8380d055c9a0">                  <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{order}.getShopItems())]]></dataSourceExpression>               </datasetRun>               <jr:column width="140" uuid="e76a1daf-5d64-4caa-9da7-2d45bcd20d14">                  <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>                  <jr:tableHeader style="Table_TH" height="30" rowSpan="1"/>                  <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>                  <jr:columnHeader style="Table_CH" height="30" rowSpan="1">                     <staticText>                        <reportElement x="0" y="0" width="140" height="30" uuid="dbb4edc3-0a65-47b3-bb12-1fb0759ab8d7"/>                        <text><![CDATA[summary from previous page]]></text>                     </staticText>                  </jr:columnHeader>                  <jr:columnFooter style="Table_CH" height="30" rowSpan="1">                     <staticText>                        <reportElement x="0" y="0" width="140" height="30" uuid="6056a74a-f337-44f3-91d3-766d851bdadf"/>                        <text><![CDATA[summary to next page]]></text>                     </staticText>                  </jr:columnFooter>                  <jr:detailCell style="Table_TD" height="20">                     <textField textAdjust="StretchHeight" isBlankWhenNull="true">                        <reportElement positionType="Float" stretchType="RelativeToTallestObject" isPrintRepeatedValues="false" x="0" y="0" width="140" height="20" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="5d71a275-98c3-4e78-95f9-d0121d1f90da"/>                        <textFieldExpression><![CDATA[$F{description}]]></textFieldExpression>                     </textField>                  </jr:detailCell>               </jr:column>               <jr:column width="100" uuid="aff7549f-d67b-4331-a90a-b61c6488ea2a">                  <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>                  <jr:tableHeader style="Table_TH" height="30" rowSpan="1"/>                  <jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>                  <jr:columnHeader style="Table_CH" height="30" rowSpan="1">                     <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>                     <textField>                        <reportElement x="0" y="0" width="100" height="30" uuid="9c496047-bc4d-4b15-88ba-e9633176998b"/>                        <textFieldExpression><![CDATA[$V{total}]]></textFieldExpression>                     </textField>                  </jr:columnHeader>                  <jr:columnFooter style="Table_CH" height="30" rowSpan="1">                     <textField>                        <reportElement x="0" y="0" width="100" height="30" uuid="26f5ee76-3047-4f15-8d69-7c9f5a489e43"/>                        <textFieldExpression><![CDATA[$V{total}]]></textFieldExpression>                     </textField>                  </jr:columnFooter>                  <jr:detailCell style="Table_TD" height="20">                     <textField textAdjust="StretchHeight" isBlankWhenNull="true">                        <reportElement positionType="Float" x="0" y="0" width="100" height="20" isPrintWhenDetailOverflows="true" uuid="5c7ddb07-8789-47c6-872d-8f297a5678f8"/>                        <textFieldExpression><![CDATA[$F{price}]]></textFieldExpression>                     </textField>                  </jr:detailCell>               </jr:column>            </jr:table>         </componentElement>      </band>   </detail>   <columnFooter>      <band height="45" splitType="Stretch"/>   </columnFooter>   <summary>      <band height="54" splitType="Stretch"/>   </summary></jasperReport>

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...