Suggestion: Snapshot Generation Should Reflect Visible Cell Formatting

Posted by: phelipe.silva on 25 March 2025, 3:13 pm EST

  • Posted 25 March 2025, 3:13 pm EST

    Hello team,

    We’ve identified an issue when generating snapshot images using the Spread Java library, where the snapshot does not fully reflect what the user sees in the spreadsheet. This causes a mismatch between the visual representation and the snapshot result, leading to confusion for end users.

    Example scenario:

    When a cell contains a date value without an explicitly applied format (e.g., Short Date), the snapshot mechanism defaults to the US format (MM/DD/YYYY). However, in our region, the expected format is DD/MM/YYYY. Once we explicitly applied the “Short Date” format to the cell, the snapshot started showing the correct format.

    This behavior is not limited to date fields — similar discrepancies were observed in:

    Text-type cells

    Charts

    Other formatted content

    Suggested Improvement:

    We’d like to propose that the snapshot generation logic should more closely reflect the visual formatting applied to cells, as seen by users in the Spread interface. Many users expect the snapshot to be an exact visual representation of the sheet, and when there are subtle differences (e.g., in date formats or cell styles), it is interpreted as a platform error.

    Ensuring that the formatting shown in the UI is preserved in the snapshot would improve consistency and enhance the user experience.

    Let us know if this is something currently being considered, or if there are any recommended workarounds beyond explicitly setting all formats manually.

    Thank you!

    Best regards,

  • Posted 27 March 2025, 1:15 am EST

    Hi,

    DsExcel works in the US culture by default. If you require to run the workbook in any other culture, it is required to set the culture using the setCulture method of the Workbook.

    Please refer to the code snippet below, which adds the date to the cell A1 of the worksheet, the date defaults to the UK culture DD/MM/YYYY format:

    https://developer.mescius.com/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IWorkbook.html#setculture

    Workbook workbook = new Workbook();
    workbook.setCulture(Locale.UK);
    IWorksheet worksheet = workbook.getActiveSheet();
    worksheet.getRange(0, 0).setValue(new Date());
    worksheet.getRange(0, 0).autoFit();
    worksheet.toImage("output.png");

    You can further refer to the attached sample that uses the code snippet above and outputs the image file in the UK culture formatted date (see below).

    Please note that setting the workbook culture will also resolve other issues you mentioned - text-type cells, charts, etc.

    Please feel free to reach out if you encounter any further issues or require additional guidance.

    Regards,

    Prabhat Sharma.

    formatting.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels