Problem when generate images from graphs

Posted by: ricardo.aleixo on 28 January 2025, 3:11 pm EST

  • Posted 28 January 2025, 3:11 pm EST - Updated 28 January 2025, 3:17 pm EST

    I am setting up a chart in my spreadJS on the frontend, with properties such as: colors, axis labels and column or row labels of the chart.

    When generating an image of this chart using the code below, the generated image does not reflect the same appearance of the spread chart.

    Snippet of the main code

    IShape iShape = recuperaIShapeDeAcordoComAbaENomeShape(bytesFile, nomeAbaGrafico, nomeGrafico);
    ImageSaveOptions options = new ImageSaveOptions();
    options.setScaleX(3.0);
    options.setScaleY(3.0);
    options.setResolution(300);
    
    iShape.toImage(outputStream, ImageType.PNG, options);
    
    private IShape recuperaIShapeDeAcordoComAbaENomeShape(byte[] bytesFile, String nomeAbaGrafico, String nomeGrafico) {
        Workbook workbook = this.abrirWorkbookPeloConteudo(bytesFile, OpenFileFormat.Sjs);
        workbook.getOptions().getFormulas().setEnableIterativeCalculation(false);
        IWorksheet aba = workbook.getWorksheets().get(nomeAbaGrafico);
        return aba.getShapes().get(nomeGrafico);
    }

    Is the information being sent to generate the image sufficient, or is it necessary to include additional properties to ensure the chart matches the desired format and appearance?

  • Posted 29 January 2025, 3:23 am EST

    Hi Ricardo,

    We created a sample chart based on your provided image in SpreadJS, exported it to an .sjs file, and then loaded it in DsExcel. When exporting the chart image using DsExcel, it correctly reflected the appearance of the SpreadJS chart. Please refer to the attached files for reference. - Files.zip

    Please note that we tested with the latest v8.0.2 release of DsExcel. There were a few issues in earlier versions related to the appearance of chart elements, which have been fixed in the latest versions. Therefore, we suggest you test your implementation with the latest v8.0.2 of DsExcel to see if it resolves the issue on your end.

    In case the issue persists, please share a sample project or .sjs file showing the issue, so we can investigate and further assist you better.

    Best Regards,

    Kartik

Need extra support?

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

Learn More

Forum Channels