jasper reports - How can I show sum of columns in column header? -


i have design jasper report in ireport 5 tool following constraints:

  1. i need show sum of each column in header in image
  2. i need show columns vertical in image

desired output

expected output

is possible design report this?

using normal detail band , columnheader band achieved creating variable calculationtype="sum" on field sum

see: how sum values in column in jaspersoft ireport designer?

then display variable using textfield in columnheader band, setting evaluationtime="report" variable calculated before displaying it.

to rotate textelement vertical use rotation attribute (rotation="left")

example:

<?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="reporttest" pagewidth="595" pageheight="842" columnwidth="555" leftmargin="20" rightmargin="20" topmargin="30" bottommargin="30" uuid="43c90ca5-f3c3-4dda-8423-9ff1442f90e3">     <querystring>         <![cdata[select * mytable]]>     </querystring>     <field name="descr" class="java.lang.string">         <fielddescription><![cdata[]]></fielddescription>     </field>     <field name="value" class="java.lang.double">         <fielddescription><![cdata[]]></fielddescription>     </field>     <variable name="sumvalue" class="java.lang.double" calculation="sum">         <variableexpression><![cdata[$f{value}]]></variableexpression>     </variable>     <columnheader>         <band height="70">             <textfield>                 <reportelement mode="opaque" x="0" y="50" width="100" height="20" forecolor="#000000" backcolor="#cccccc" uuid="dfe13f55-12a6-4c33-b5ba-00dd61f37c96"/>                 <box leftpadding="2">                     <toppen linewidth="0.25"/>                     <leftpen linewidth="0.25"/>                     <bottompen linewidth="0.25"/>                     <rightpen linewidth="0.25"/>                 </box>                 <textelement verticalalignment="middle"/>                 <textfieldexpression><![cdata["totale"]]></textfieldexpression>             </textfield>             <textfield evaluationtime="report" pattern="###0.00;-###0.00">                 <reportelement mode="opaque" x="100" y="50" width="100" height="20" forecolor="#000000" backcolor="#cccccc" uuid="ed251db0-474e-4e20-8788-3c2f08bfd1e7"/>                 <box leftpadding="2" rightpadding="2">                     <toppen linewidth="0.25"/>                     <leftpen linewidth="0.25"/>                     <bottompen linewidth="0.25"/>                     <rightpen linewidth="0.25"/>                 </box>                 <textelement textalignment="right" verticalalignment="middle"/>                 <textfieldexpression><![cdata[$v{sumvalue}]]></textfieldexpression>             </textfield>             <statictext>                 <reportelement mode="opaque" x="100" y="0" width="100" height="50" forecolor="#000000" backcolor="#cccccc" uuid="62b62711-8cfb-4df2-8f9e-4a34249dcc66"/>                 <box leftpadding="2">                     <toppen linewidth="0.25"/>                     <leftpen linewidth="0.25"/>                     <bottompen linewidth="0.25"/>                     <rightpen linewidth="0.25"/>                 </box>                 <textelement textalignment="center" verticalalignment="middle" rotation="left">                     <font size="8"/>                 </textelement>                 <text><![cdata[sessions]]></text>             </statictext>         </band>     </columnheader>     <detail>         <band height="20" splittype="immediate">             <textfield>                 <reportelement x="0" y="0" width="100" height="20" uuid="6a009a8c-16de-451c-a0f1-516a48f793d0"/>                 <box leftpadding="2">                     <toppen linewidth="0.25"/>                     <leftpen linewidth="0.25"/>                     <bottompen linewidth="0.25"/>                     <rightpen linewidth="0.25"/>                 </box>                 <textelement verticalalignment="middle">                     <paragraph linespacing="single"/>                 </textelement>                 <textfieldexpression><![cdata[$f{descr}]]></textfieldexpression>             </textfield>             <textfield pattern="###0.00;-###0.00">                 <reportelement x="100" y="0" width="100" height="20" uuid="1fccff95-408c-4364-b003-c691fefdde62"/>                 <box rightpadding="2">                     <toppen linewidth="0.25"/>                     <leftpen linewidth="0.25"/>                     <bottompen linewidth="0.25"/>                     <rightpen linewidth="0.25"/>                 </box>                 <textelement textalignment="right" verticalalignment="middle">                     <paragraph linespacing="single"/>                 </textelement>                 <textfieldexpression><![cdata[$f{value}]]></textfieldexpression>             </textfield>         </band>     </detail> </jasperreport> 

result (with arbitrary data)

result


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -