Report Formatting

Comments

3 comments

  • Benjamin 'Bigs' Coppel

    Hi Andrew-

    1. Most likely the data comes into the report as a text string, not as an actual date, so normal methods for date formatting will not work. The method for reformatting a date which is in string format is to use SimpleDateFormat to parse the string into a date and then format it as desired.

    Put the following code in your text element. I've taken a stab at the input parse string (the second one) and the output format strings (first one) but you may need to adjust. I've done this in American format, you should swap the M's and d's if you're in the rest of the world. Also change the field name at the end to your input field. See https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html for all available format characters.

    new SimpleDateFormat("MM/dd/yyyy").format((new SimpleDateFormat("M/d/yyyy HH:mma")).parse($F{dateStringField}))

    2. Just to clarify - are you saying that if an item is indented, you also want the note to be indented? Use a conditional style.

    • Create a style called Note with indent 0
    • Add a conditional style with condition $F{description}.startsWith("   ") - this means the conditional style will activate when the item description starts with spaces, which is how the indent comes through in the report data.
    • Set the indent in the conditional style to your desired amount
    • Set the note text element in the detail band to use the Note style. Now it will be indented when the description is indented.

    If you need any more help on these, feel free to reach out to me via email.

    Cheers,

    Benjamin 'Bigs' Coppel
    Endorsed Flex Consultant and Report Developer
    bigs@squarewave.com.au
    www.squarewave.com.au

    0
    Comment actions Permalink
  • Andrew

    Nearly every thread I find references converting the field from a string. Is that something that will work with Flex?

    0
    Comment actions Permalink
  • Benjamin 'Bigs' Coppel

    Hi Andrew-

    I replied but the post is pending approval for some reason. Re-posting here, hopefully it works this time:

    Hi Andrew-

    1. Most likely the data comes into the report as a text string, not as an actual date, so normal methods for date formatting will not work. The method for reformatting a date which is in string format is to use SimpleDateFormat to parse the string into a date and then format it as desired.

    Put the following code in your text element. I've taken a stab at the input parse string (the second one) and the output format strings (first one) but you may need to adjust. I've done this in American format, you should swap the M's and d's if you're in the rest of the world. Also change the field name at the end to your input field. Google 'simpledateformat reference java platform SE 7' for the full reference with all allowed characters.

    new SimpleDateFormat("MM/dd/yyyy").format((new SimpleDateFormat("M/d/yyyy HH:mma")).parse($F{dateStringField}))

    2. Just to clarify - are you saying that if an item is indented, you also want the note to be indented? Use a conditional style.

    • Create a style called Note with indent 0
    • Add a conditional style with condition $F{description}.startsWith("   ") - this means the conditional style will activate when the item description starts with spaces, which is how the indent comes through in the report data.
    • Set the indent in the conditional style to your desired amount
    • Set the note text element in the detail band to use the Note style. Now it will be indented when the description is indented.

    If you need any more help on these, feel free to reach out to me via email.

    Cheers,

    Benjamin 'Bigs' Coppel
    Endorsed Flex Consultant and Report Developer

    0
    Comment actions Permalink

Please sign in to leave a comment.