Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

how to set Excel cell format using XML file

  • 19-04-2005 10:40am
    #1
    Registered Users, Registered Users 2 Posts: 4,225 ✭✭✭


    I'm working on a java program that uses a 3rd party component called JasperReports to produce reports on a db and export them to an excel spread sheet based on an xml document.
    The porblem i'm having is if i am exporting a string of say "0987654321" to the spread sheet the "0" at the start gets dropped and it becomes "987654321".
    I know when manuallt editing an excel cell you just right click on it and set the format to "Text" and it works but does anyone know how to set this programatically through xml?


Comments

  • Closed Accounts Posts: 25 dan_pretty_boy


    Hi,

    You could set the element to be a CDATA element meaning it will just display what ever the value is


    danny


  • Registered Users, Registered Users 2 Posts: 4,225 ✭✭✭Scruff


    Hi danny,

    i'm already doing this but Excel seems to be ignoring it.
    Heres the xml for the jasper component i'm using:

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

    <reportElement mode="Opaque" x="115" y="0" width="80" height="20" forecolor="#000000" backcolor="#FFFFFF" key="textField-2" stretchType="NoStretch" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/>

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

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

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

    </textElement>

    <textFieldExpression class="java.lang.String"><!b]CDATA[/b][[/color][/size][size=1]$F{Shortcode}[/size][size=1][color=#0000ff]></textFieldExpression>

    </textField>



  • Closed Accounts Posts: 25 dan_pretty_boy


    Hi,


    If your using the CDATA section try and remove the pattern attribute and see what happens.


    danny


Advertisement