Results 1 to 13 of 13
  1. #1
    Deepa is offline Member
    Join Date
    Nov 2008
    Posts
    85
    Rep Power
    0

    Post How to trim the value in jrxml code

    Hi,
    I wish to generate the pdf file from jrxml.Here i would like to trim the Field value .Here i use the query in java.But i would like to trim the value in jrxml.
    Plz help anyone ,how to trim the field.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  3. #3
    Deepa is offline Member
    Join Date
    Nov 2008
    Posts
    85
    Rep Power
    0

    Default Re:

    Hi,
    In the below eg,How to trim the TOTALAMOUNT(Field) Value...


    <?xml version="1.0"?>
    <jasperReport
    name="SimpleReport"
    columnCount="1"
    printOrder="Horizontal"
    orientation="Portrait"
    pageWidth="800"
    pageHeight="842"
    columnWidth="535"
    columnSpacing="0"
    leftMargin="30"
    rightMargin="30"
    topMargin="20"
    bottomMargin="20"
    whenNoDataType="NoPages"
    isTitleNewPage="false"
    isSummaryNewPage="false">

    <field name="TOTALCNT" class="java.lang.String"/>
    <field name="TOTALAMOUNT" class="java.lang.String"/>
    <title>
    <band height="50" isSplitAllowed="true">
    <staticText>

    <reportElement
    mode="Transparent"
    x="200"
    y="6"
    width="345"
    height="39"
    forecolor="#0000CC"
    backcolor="#FFFFFF"
    key="staticText-1"
    stretchType="NoStretch"
    positionType="FixRelativeToTop"
    isPrintRepeatedValues="true"
    isRemoveLineWhenBlank="false"
    isPrintInFirstWholeBand="false"
    isPrintWhenDetailOverflows="false" />

    <box
    topBorder="None"
    topBorderColor="#000000"
    leftBorder="None"
    leftBorderColor="#000000"
    rightBorder="None"
    rightBorderColor="#000000"
    bottomBorder="None"
    bottomBorderColor="#000000" />

    <textElement
    textAlignment="Center"
    verticalAlignment="Top"
    rotation="None"
    lineSpacing="Single">

    <font
    fontName="Arial"
    pdfFontName="Helvetica-Bold"
    size="10"
    isBold="true"
    isItalic="false"
    isUnderline="false"
    isPdfEmbedded="false"
    pdfEncoding="Cp1252"
    isStrikeThrough="false" />
    </textElement>

    <text><![CDATA[REPORT]]></text>
    </staticText>
    </band>
    </title>

    <pageHeader>
    <band height="18">

    <staticText>
    <reportElement
    mode="Transparent"
    x="0"
    y="0"
    width="50"
    height="18"
    forecolor="#0000CC"
    backcolor="#FFFFFF"
    key="staticText-2"
    stretchType="NoStretch"
    positionType="FixRelativeToTop"
    isPrintRepeatedValues="true"
    isRemoveLineWhenBlank="false"
    isPrintInFirstWholeBand="false"
    isPrintWhenDetailOverflows="false" />

    <box
    topBorder="None"
    topBorderColor="#000000"
    leftBorder="None"
    leftBorderColor="#000000"
    rightBorder="None"
    rightBorderColor="#000000"
    bottomBorder="None"
    bottomBorderColor="#000000" />

    <textElement
    textAlignment="Left"
    verticalAlignment="Top"
    rotation="None"
    lineSpacing="Single">
    <font
    fontName="Arial"
    pdfFontName="Helvetica-Bold"
    size="9"
    isBold="true"
    isItalic="false"
    isUnderline="false"
    isPdfEmbedded="false"
    pdfEncoding="Cp1252"
    isStrikeThrough="false" />
    </textElement>

    <text><![CDATA[TOTALCNT]]></text>
    </staticText>


    <staticText>
    <reportElement
    mode="Transparent"
    x="70"
    y="0"
    width="100"
    height="18"
    forecolor="#0000CC"
    backcolor="#FFFFFF"
    key="staticText-2"
    stretchType="NoStretch"
    positionType="FixRelativeToTop"
    isPrintRepeatedValues="true"
    isRemoveLineWhenBlank="false"
    isPrintInFirstWholeBand="false"
    isPrintWhenDetailOverflows="false" />

    <box
    topBorder="None"
    topBorderColor="#000000"
    leftBorder="None"
    leftBorderColor="#000000"
    rightBorder="None"
    rightBorderColor="#000000"
    bottomBorder="None"
    bottomBorderColor="#000000" />

    <textElement
    textAlignment="Left"
    verticalAlignment="Top"
    rotation="None"
    lineSpacing="Single">
    <font
    fontName="Arial"
    pdfFontName="Helvetica-Bold"
    size="9"
    isBold="true"
    isItalic="false"
    isUnderline="false"
    isPdfEmbedded="false"
    pdfEncoding="Cp1252"
    isStrikeThrough="false" />
    </textElement>

    <text><![CDATA[TOTALAMOUNT]]></text>
    </staticText>
    </band>
    </pageHeader>

    <detail>
    <band height="20">

    <textField
    isStretchWithOverflow="false"
    pattern=""
    isBlankWhenNull="false"
    evaluationTime="Now"
    hyperlinkType="None"
    hyperlinkTarget="Self"
    bookmarkLevel="0">

    <reportElement
    mode="Transparent"
    x="0"
    y="0"
    width="50"
    height="18"
    forecolor="#000000"
    backcolor="#FFFFFF"
    key="textField"
    stretchType="NoStretch"
    positionType="FixRelativeToTop"
    isPrintRepeatedValues="true"
    isRemoveLineWhenBlank="false"
    isPrintInFirstWholeBand="false"
    isPrintWhenDetailOverflows="false" />

    <box
    topBorder="None"
    topBorderColor="#000000"
    leftBorder="None"
    leftBorderColor="#000000"
    rightBorder="None"
    rightBorderColor="#000000"
    bottomBorder="None"
    bottomBorderColor="#000000" />

    <textElement
    textAlignment="Left"
    verticalAlignment="Top"
    rotation="None"
    lineSpacing="Single">
    <font
    fontName="Arial"
    pdfFontName="Helvetica"
    size="8"
    isBold="false"
    isItalic="false"
    isUnderline="false"
    isPdfEmbedded="false"
    pdfEncoding="Cp1252"
    isStrikeThrough="false" />
    </textElement>

    <textFieldExpression class="java.lang.String">
    <![CDATA[$F{TOTALCNT}]]>
    </textFieldExpression>
    </textField>




    <textField
    isStretchWithOverflow="false"
    pattern=""
    isBlankWhenNull="false"
    evaluationTime="Now"
    hyperlinkType="None"
    hyperlinkTarget="Self"
    bookmarkLevel="0">

    <reportElement
    mode="Transparent"
    x="70"
    y="0"
    width="100"
    height="18"
    forecolor="#000000"
    backcolor="#FFFFFF"
    key="textField"
    stretchType="NoStretch"
    positionType="FixRelativeToTop"
    isPrintRepeatedValues="true"
    isRemoveLineWhenBlank="false"
    isPrintInFirstWholeBand="false"
    isPrintWhenDetailOverflows="false" />

    <box
    topBorder="None"
    topBorderColor="#000000"
    leftBorder="None"
    leftBorderColor="#000000"
    rightBorder="None"
    rightBorderColor="#000000"
    bottomBorder="None"
    bottomBorderColor="#000000" />

    <textElement
    textAlignment="Left"
    verticalAlignment="Top"
    rotation="None"
    lineSpacing="Single">
    <font
    fontName="Arial"
    pdfFontName="Helvetica"
    size="8"
    isBold="false"
    isItalic="false"
    isUnderline="false"
    isPdfEmbedded="false"
    pdfEncoding="Cp1252"
    isStrikeThrough="false" />
    </textElement>

    <textFieldExpression class="java.lang.String">
    <![CDATA[$F{TOTALAMOUNT}]]>
    </textFieldExpression>
    </textField>
    </band>
    </detail>

    <columnFooter>
    <band height="9" isSplitAllowed="true" />
    </columnFooter>

    <pageFooter>
    <band height="40" isSplitAllowed="true">
    <line direction="TopDown">
    <reportElement x="0" y="10" width="800" height="1" positionType="FixRelativeToTop" stretchType="NoStretch" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false" />
    <graphicElement />
    </line>
    <textField isStretchWithOverflow="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" bookmarkLevel="0">
    <reportElement x="200" y="20" width="80" height="15" positionType="FixRelativeToTop" stretchType="NoStretch" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false" />
    <textElement textAlignment="Right" />
    <textFieldExpression class="java.lang.String">
    <![CDATA[ "Page " + String.valueOf($V{PAGE_NUMBER}) + " of"]]>
    </textFieldExpression>
    </textField>
    <textField evaluationTime="Report" isStretchWithOverflow="false" hyperlinkType="None" hyperlinkTarget="Self" bookmarkLevel="0">
    <reportElement x="280" y="20" width="75" height="15" positionType="FixRelativeToTop" stretchType="NoStretch" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false" />
    <textElement />
    <textFieldExpression class="java.lang.String">
    <![CDATA[ " " + String.valueOf($V{PAGE_NUMBER})
    ]]>
    </textFieldExpression>
    </textField>
    </band>
    </pageFooter>


    </jasperReport>

  4. #4
    gustio is offline Member
    Join Date
    Jun 2008
    Posts
    14
    Rep Power
    0

    Default

    I am not sure what do you mean. But, I used trim function at database query (SQL iReport). I think you can Cast number value to String value, then used trim function. Hope help

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    First of all try to explain your question more clearly. You have post a large code here, I don't think anyone knows what you need to have there.


  6. #6
    Deepa is offline Member
    Join Date
    Nov 2008
    Posts
    85
    Rep Power
    0

    Default Re

    Hi Ergana,
    How to trim the String value .This string is get it from query and used in jrxml.How to trim the string value by using jrxml code.

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    I don't know what jrxml code do. What trim done on String in Java is, remove all starting and ending spaces.

  8. #8
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default What do you mean by trim?

    Deepa... to you, what does trim mean?

    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  9. #9
    Deepa is offline Member
    Join Date
    Nov 2008
    Posts
    85
    Rep Power
    0

    Default Re:

    I want to remove the spaces.I mean,
    For an eg:
    String amt=" 12,000.00";
    System.out.println("amt:"+amt.trim())

    Output:
    amt:12,000.
    This is done by java code.But what i'm required means,i get the amt value from database and after that i will trim that amt value by using jrxml code.

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  11. #11
    Deepa is offline Member
    Join Date
    Nov 2008
    Posts
    85
    Rep Power
    0

    Default Re:

    To remove spaces at the start of string value.But this is done by jrxml code.

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  13. #13
    rasikow is offline Member
    Join Date
    Dec 2008
    Posts
    3
    Rep Power
    0

    Post How to give conditions in jrxml ? (Jasper Report)

    Hi all,

    i want to give condition in my jrxml file.

    For example, i am fetching one fields "currentStatus", Integer data type

    if current status equal to 9, it should display "Submitted"
    if 10, "placed"
    if 11, blah blah.....etc...

    How to do that?

    Thanks in advance.

    - Gnaniyar Zubair

Similar Threads

  1. Replies: 2
    Last Post: 12-03-2008, 11:14 AM
  2. How to trim text in viewer
    By diva_garg in forum SWT / JFace
    Replies: 4
    Last Post: 08-26-2008, 02:03 PM
  3. I need help fixing my code.. or non code?
    By MrHuggykins in forum New To Java
    Replies: 1
    Last Post: 03-19-2008, 10:12 PM
  4. String trim
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-21-2008, 04:35 PM
  5. Replies: 1
    Last Post: 04-26-2007, 03:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •