Jump to content
  • Excel Number Formatting


    gsalas
    Assigned User teodord
    CategoryFeature request
    PriorityHigh
    ReproducibilityAlways
    ResolutionFixed
    SeverityMajor
    StatusClosed
    Currently jasper provides a number of formats that can be exported to excel and the reports displays the results in the format chosen, you specify two decimal places the content of the cell will have two decimal places and the cell will display the two decimal places. Working in the financial industry this come times is a problem because what is displayed in the cell and what its contents are become very important. Lets use an example of a stock price where its value can contain as much as 8 decimal places ($48.68494858) When reconciling different reports everyone of those decimal makes an important difference in calculation, the look of the report is also important because to the user they do not want to be overwhelmed with too much details.


    User Feedback

    Recommended Comments

    At the moment we have come up with a work around using java to replicate an accounting format in excel, where the contents in the cell are untouched and it is formatted to no decimal places with negatives wrapped in brackets.

     

    JRXlsExporter exporter = new JRXlsExporter();

    exporter.setParameter(JRXlsExporterParameter.JASPER_PRINT, print);

    exporter.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, outputStream);

    exporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);

    exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);

    Map numberFormats = new HashMap();

    numberFormats.put("#,##0.0000000000", "_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)");

    exporter.setParameter(JRXlsExporterParameter.FORMAT_PATTERNS_MAP, numberFormats);

    exporter.exportReport();

    render(response, outputStream);

     

    As you can see we would need to add a new mapping for each format where we would like the contents of the cell unchanged.

    Link to comment
    Share on other sites

    Hi,

     

    Can you try the latest JR version and see if the precision is there?

    We recently made some modifications so that we preserve the actual value of the text field. So although we format the value when we show it, behind the scenes, when you want to edit the cell in Excel, you can see it has more decimals than it shows.

     

    Thanks,

    Teodor

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