Jump to content
Changes to the Jaspersoft community edition download ×

How to remove the last separator from a header/footer of a csv report?


btissam.ghazi

Recommended Posts

Hi,

I am using iReport 3.0 for report development and I'm new in JasperReports.

I have a report which generate a csv file, but i need to remove the Extra separator at the end of both the header and footer lines:

H;201905;file;
D;toto;titi;tata
D;tyty;tutu;tete
T;2;;

Where :
•H..is the header line
•D is the detail
•And T is the footer line

So please advise how can I remove the last semicoolon (Or whatever separator) from the lines:
1-H;201905;file
And
2-T;2

The result expected should be then:

H;201905;file
D;toto;titi;tata
D;tyty;tutu;tete
T;2

Thanks !

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi,

 

Here is the code:

 

<?xml version="1.0" encoding="UTF-8"  ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
   name="change_order_return_status"
   columnCount="1"
   printOrder="Vertical"
   orientation="Landscape"
   pageWidth="1000"
   pageHeight="595"
   columnWidth="902"
   columnSpacing="0"
   leftMargin="49"
   rightMargin="49"
   topMargin="49"
   bottomMargin="49"
   whenNoDataType="NoPages"
   isTitleNewPage="false"
   isSummaryNewPage="false">
 <property name="net.sf.jasperreports.export.csv.remove.empty.space.between.rows" value="true" />
 <property name="net.sf.jasperreports.print.keep.full.text" value="true" />
 <property name="net.sf.jasperreports.export.csv.exclude.origin.band.mainReport" value="pageFooter" />
 <property name="net.sf.jasperreports.export.csv.exclude.origin.band.mainReport" value="pageHeader" />
 <property name="net.sf.jasperreports.export.csv.field.delimiter" value=";" />
 <property name="net.sf.jasperreports.export.csv.remove.empty.space.between.columns" value="true" />
 <property name="net.sf.jasperreports.export.xls.exclude.origin.band.mainReport" value="pageFooter" />
 <property name="net.sf.jasperreports.export.xls.exclude.origin.band.2" value="pageFooter" />
 <property name="ireport.scriptlethandling" value="0" />
 <property name="ireport.encoding" value="UTF-8" />
 <import value="java.util.*" />
 <import value="net.sf.jasperreports.engine.*" />
 <import value="net.sf.jasperreports.engine.data.*" />

 <queryString><![CDATA[select to_char(sysdate,'yyyymmdd:hh24miss')   as "HEADER_LABEL",
                        case when b.siteid in (14,2) then substr(FILENAME,1,instr(FILENAME,'xls',1)-2)  else FILENAME end as "HEADER_LABEL1",
                        record_identifier as "RECORD_IDENTIFIER",
                        change_order_id as "CHANGE_ORDER_ID",
                        unique_identifier as "UNIQUE_IDENTIFIER",
                        decode(a.status, 'SUCCESS','S','F')  as "STATUS"
                        from pulls_download  a,cards b,PULLS_DOWNLOAD_FILES c
                        where a.unique_identifier=b.uniqueidentifier
                        and a.PULLS_DOWNLOAD_FILESSEQ_ID=c.PULLS_DOWNLOAD_FILESSEQ_ID
                        and to_char(a.PULL_DEF_DATE_UTC0,'ddmmyyyy')=to_char(trunc(sys_extract_utc(systimestamp(0))),'ddmmyyyy')]]></queryString>

 <field name="HEADER_LABEL" class="java.lang.String"/>
 <field name="RECORD_IDENTIFIER" class="java.lang.String"/>
 <field name="CHANGE_ORDER_ID" class="java.lang.String"/>
 <field name="UNIQUE_IDENTIFIER" class="java.lang.String"/>
 <field name="STATUS" class="java.lang.String"/>
 <field name="HEADER_LABEL1" class="java.lang.String"/>


  <group  name="Replication" isStartNewPage="true" >
   <groupExpression><![CDATA[]]></groupExpression>
   <groupHeader>
   <band height="40"  isSplitAllowed="true" >
    <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
     <reportElement
      mode="Opaque"
      x="445"
      y="4"
      width="239"
      height="30"
      forecolor="#FFFFFF"
      backcolor="#0066CC"
      key="title-2"/>
     <box leftPadding="2" topPadding="3" bottomPadding="2">     <pen lineWidth="0.0" lineColor="#FFFFFF"/>
     <topPen lineWidth="0.0" lineColor="#FFFFFF"/>
     <leftPen lineWidth="0.0" lineColor="#FFFFFF"/>
     <bottomPen lineWidth="0.0" lineColor="#FFFFFF"/>
     <rightPen lineWidth="0.0" lineColor="#FFFFFF"/>
</box>
     <textElement textAlignment="Center" verticalAlignment="Middle">
      <font fontName="Arial" pdfFontName="Helvetica-Bold" size="14" isBold="true"/>
     </textElement>
    <textFieldExpression   class="java.lang.String"><![CDATA[$F{HEADER_LABEL1}]]></textFieldExpression>
    </textField>
    <staticText>
     <reportElement
      mode="Opaque"
      x="5"
      y="4"
      width="141"
      height="30"
      forecolor="#FFFFFF"
      backcolor="#0066CC"
      key="staticText-2"/>
     <box></box>
     <textElement textAlignment="Center" verticalAlignment="Middle">
      <font pdfFontName="Helvetica-Bold" size="14" isBold="true"/>
     </textElement>
    <text><![CDATA[H]]></text>
    </staticText>
    <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
     <reportElement
      mode="Opaque"
      x="146"
      y="4"
      width="297"
      height="30"
      forecolor="#FFFFFF"
      backcolor="#0066CC"
      key="title-3"/>
     <box leftPadding="2" topPadding="3" bottomPadding="2">     <pen lineWidth="0.0" lineColor="#FFFFFF"/>
     <topPen lineWidth="0.0" lineColor="#FFFFFF"/>
     <leftPen lineWidth="0.0" lineColor="#FFFFFF"/>
     <bottomPen lineWidth="0.0" lineColor="#FFFFFF"/>
     <rightPen lineWidth="0.0" lineColor="#FFFFFF"/>
</box>
     <textElement textAlignment="Center" verticalAlignment="Middle">
      <font fontName="Arial" pdfFontName="Helvetica-Bold" size="14" isBold="true"/>
     </textElement>
    <textFieldExpression   class="java.lang.String"><![CDATA[$F{HEADER_LABEL}]]></textFieldExpression>
    </textField>
   </band>
   </groupHeader>
   <groupFooter>
   <band height="36"  isSplitAllowed="true" >
    <staticText>
     <reportElement
      mode="Opaque"
      x="5"
      y="6"
      width="141"
      height="30"
      forecolor="#000099"
      backcolor="#FFFFFF"
      key="staticText-1"/>
     <box>     <pen lineWidth="0.5" lineColor="#006699"/>
     <topPen lineWidth="0.5" lineColor="#006699"/>
     <leftPen lineWidth="0.5" lineColor="#006699"/>
     <bottomPen lineWidth="0.5" lineColor="#006699"/>
     <rightPen lineWidth="0.5" lineColor="#006699"/>
</box>
     <textElement textAlignment="Center" verticalAlignment="Middle">
      <font/>
     </textElement>
    <text><![CDATA[T]]></text>
    </staticText>
    <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
     <reportElement
      mode="Opaque"
      x="146"
      y="6"
      width="297"
      height="30"
      forecolor="#FFFFFF"
      backcolor="#0066CC"
      key="title-4"/>
     <box leftPadding="2" topPadding="3" bottomPadding="2">     <pen lineWidth="0.0" lineColor="#FFFFFF"/>
     <topPen lineWidth="0.0" lineColor="#FFFFFF"/>
     <leftPen lineWidth="0.0" lineColor="#FFFFFF"/>
     <bottomPen lineWidth="0.0" lineColor="#FFFFFF"/>
     <rightPen lineWidth="0.0" lineColor="#FFFFFF"/>
</box>
     <textElement textAlignment="Left" verticalAlignment="Middle">
      <font fontName="Arial" pdfFontName="Helvetica-Bold" size="14" isBold="true"/>
     </textElement>
    <textFieldExpression   class="java.lang.Integer"><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
    </textField>
   </band>
   </groupFooter>
  </group>
  <background>
   <band height="0"  isSplitAllowed="true" >
   </band>
  </background>
  <title>
   <band height="61"  isSplitAllowed="true" >
   </band>
  </title>
  <pageHeader>
   <band height="0"  isSplitAllowed="true" >
   </band>
  </pageHeader>
  <columnHeader>
   <band height="0"  isSplitAllowed="true" >
   </band>
  </columnHeader>
  <detail>
   <band height="30"  isSplitAllowed="true" >
    <textField isStretchWithOverflow="true" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
     <reportElement
      mode="Opaque"
      x="680"
      y="0"
      width="221"
      height="30"
      forecolor="#000099"
      backcolor="#FFFFFF"
      key="status-textfield"/>
     <box>     <pen lineWidth="0.5" lineColor="#006699"/>
     <topPen lineWidth="0.5" lineColor="#006699"/>
     <leftPen lineWidth="0.5" lineColor="#006699"/>
     <bottomPen lineWidth="0.5" lineColor="#006699"/>
     <rightPen lineWidth="0.5" lineColor="#006699"/>
</box>
     <textElement textAlignment="Center" verticalAlignment="Middle">
      <font fontName="Arial" pdfFontName="Helvetica-Bold" size="9" isBold="true"/>
     </textElement>
    <textFieldExpression   class="java.lang.String"><![CDATA[$F{STATUS}]]></textFieldExpression>
    </textField>
    <textField isStretchWithOverflow="true" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
     <reportElement
      mode="Opaque"
      x="445"
      y="0"
      width="239"
      height="30"
      forecolor="#000099"
      backcolor="#FFFFFF"
      key="uniqueidentifier-textfield"/>
     <box>     <pen lineWidth="0.5" lineColor="#006699"/>
     <topPen lineWidth="0.5" lineColor="#006699"/>
     <leftPen lineWidth="0.5" lineColor="#006699"/>
     <bottomPen lineWidth="0.5" lineColor="#006699"/>
     <rightPen lineWidth="0.5" lineColor="#006699"/>
</box>
     <textElement textAlignment="Center" verticalAlignment="Middle">
      <font fontName="Arial" pdfFontName="Helvetica-Bold" size="9" isBold="true"/>
     </textElement>
    <textFieldExpression   class="java.lang.String"><![CDATA[$F{UNIQUE_IDENTIFIER}]]></textFieldExpression>
    </textField>
    <textField isStretchWithOverflow="true" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
     <reportElement
      mode="Opaque"
      x="146"
      y="0"
      width="297"
      height="30"
      forecolor="#000099"
      backcolor="#FFFFFF"
      key="changeorderid-textfield"/>
     <box>     <pen lineWidth="0.5" lineColor="#006699"/>
     <topPen lineWidth="0.5" lineColor="#006699"/>
     <leftPen lineWidth="0.5" lineColor="#006699"/>
     <bottomPen lineWidth="0.5" lineColor="#006699"/>
     <rightPen lineWidth="0.5" lineColor="#006699"/>
</box>
     <textElement textAlignment="Center" verticalAlignment="Middle">
      <font fontName="Arial" pdfFontName="Helvetica-Bold" size="9" isBold="true"/>
     </textElement>
    <textFieldExpression   class="java.lang.String"><![CDATA[$F{CHANGE_ORDER_ID}]]></textFieldExpression>
    </textField>
    <textField isStretchWithOverflow="true" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
     <reportElement
      mode="Opaque"
      x="5"
      y="0"
      width="141"
      height="30"
      forecolor="#000099"
      backcolor="#FFFFFF"
      key="changeorderid-1"/>
     <box>     <pen lineWidth="0.5" lineColor="#006699"/>
     <topPen lineWidth="0.5" lineColor="#006699"/>
     <leftPen lineWidth="0.5" lineColor="#006699"/>
     <bottomPen lineWidth="0.5" lineColor="#006699"/>
     <rightPen lineWidth="0.5" lineColor="#006699"/>
</box>
     <textElement textAlignment="Center" verticalAlignment="Middle">
      <font fontName="Arial" pdfFontName="Helvetica-Bold" size="9" isBold="true"/>
     </textElement>
    <textFieldExpression   class="java.lang.String"><![CDATA[$F{RECORD_IDENTIFIER}]]></textFieldExpression>
    </textField>
   </band>
  </detail>
  <columnFooter>
   <band height="0"  isSplitAllowed="true" >
   </band>
  </columnFooter>
  <pageFooter>
   <band height="14"  isSplitAllowed="true" >
   </band>
  </pageFooter>
  <summary>
   <band height="0"  isSplitAllowed="true" >
   </band>
  </summary>
</jasperReport>

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