SpreadJS can't export frozen rows data when using columnHeadersAsFrozenRows

Posted by: ngocnguyen09910060 on 28 November 2021, 5:25 am EST

    • Post Options:
    • Link

    Posted 28 November 2021, 5:25 am EST

    Hi teams,

    On my web application, i’m using sheet.frozenRowCount(5) to freeze 5 rows.

    When i implement export feature with Excel.IO, 5 frozen rows is exported as my expectation.

    But when i using this configuration:

    serializationOption = {

    columnHeadersAsFrozenRows: true,

    };


    to export header as a frozen row, 5 above rows are not frozen in my exported file.

    How can i export both header and 5 rows as frozen rows ?

  • Posted 30 November 2021, 1:48 am EST

    Hi,

    The observed behaviour is by design, if you need to export the column headers + frozen rows as frozen, then you may set the frozenRowCount on the workbook JSON before exporting to excel. You may refer to the following code snippet and the sample demonstrating the same:

    function exportExcelWithFrozenRowsAndColumnHeaders(spread) {
        var wbJson = spread.toJSON({
            columnHeadersAsFrozenRows: true,
            includeBindingData: true
        });
        // update json to include frozen rows too
        spread.sheets.forEach(sheet => {
            var sheetName = sheet.name();
            var frozenCount = sheet.frozenRowCount();
            if(!frozenCount){
                return;
            }
    
            // update frozen count
            wbJson.sheets[sheetName].frozenRowCount += frozenCount;
            wbJson.sheets[sheetName].topCellIndex = frozenCount + 1;
            
        });
    
        excelIo.save(wbJson, function (blob) {
            console.log("saved");
            saveAs(blob, "sample.xlsx");
        } );
    }
    

    https://jscodemine.grapecity.com/share/RWBEkKYP_kK2CALBWWUOPA/

    Regards

    Sharad

Need extra support?

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

Learn More

Forum Channels