ExcelIO exported file does not set RTL to sheet

Posted by: adam.e.clark on 23 October 2024, 3:08 am EST

    • Post Options:
    • Link

    Posted 23 October 2024, 3:08 am EST

    Issue: Setting Right-to-Left for the active sheet and exporting the Excel file. While all updates are reflected in the exported file, the Right-to-Left option is not present.

    Package versions:

    @grapecity/spread-excelio: 17.1.7

    @grapecity/spread-sheets: 17.1.7

    @grapecity/spread-sheets-react: 17.1.0

    @grapecity/spread-sheets-designer: 17.1.7

    @grapecity/spread-sheets-designer-react: 17.1.7

    import * as ExcelIO from '@grapecity/spread-excelio';
    import GCDesigner from '@grapecity/spread-sheets-designer';
    
    export const getWorkbookJSONFromDesigner = (
        designer: GCDesigner.Spread.Sheets.Designer.Designer,
    ) => {
        const workbook = designer.getWorkbook();
        // @ts-ignore toJSON does not exist
        return JSON.stringify(workbook.toJSON());
    };
    
    export const getExcelBlobFromDesignerJSON = (
        designer: GCDesigner.Spread.Sheets.Designer.Designer,
    ): Promise<Blob> => {
        const json = getWorkbookJSONFromDesigner(designer);
        const excelIO = new ExcelIO.IO();
    
        return new Promise((resolve, reject) => {
            excelIO.save(
                json,
                (blob: Blob) => resolve(blob),
                (error: any) => reject(error),
            );
        });
    };
    
    const excelBlob = await getExcelBlobFromDesignerJSON(designer);
    const file = new File([excelBlob], fileName);
  • Posted 23 October 2024, 7:08 am EST

    Hi,

    We were able to replicate the behavior on our end.

    It appears that you’re using the excelio module to save the SJS file as an Excel file, and the right-to-left setting is not being retained in the saved file.

    Since excelio is an older module, we recommend switching to the newer spreadio module for exporting Excel files. The spreadio module offers better performance and ensures that the right-to-left setting persists in the Excel file after saving. Please refer to the attached sample.

    Sample: https://jscodemine.mescius.io/share/1r7tYdoI_0OqV4qZFudOgA/?defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fsrc%2Fapp.jsx"]%2C"ActiveFile"%3A"%2Fsrc%2Fapp.jsx"}

    References:

    Export: https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Sheets.Workbook#export

    Regards,

    Priyam

Need extra support?

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

Learn More

Forum Channels