Export functionality in Spread Js :- remove unnecessary columns

Posted by: Shalini89garg on 12 February 2018, 10:04 pm EST

    • Post Options:
    • Link

    Posted 12 February 2018, 10:04 pm EST

    In spread Js , I have one column for numbering and one for checkbox and other fields are like Name , Month value

    While Export into Excel, I do not want to see these two columns (check box, and Numbering) , but still its visible , how can i remove these columns

    I am using below code for export

    let excelIo = new GC.Spread.Excel.IO();
            var json = this.spread.toJSON({
                includeBindingSource: true,
                rowHeadersAsFrozenColumns: true,
                columnHeadersAsFrozenRows: true,
                ignoreFormula: false,
                ignoreStyle: false
            });
            let sheetsNames = Object.getOwnPropertyNames(json.sheets);
            sheetsNames.forEach(sheetname => {
                const option = {
                    allowFilter: true,
                    allowSort: true,
                    allowResizeRows: true,
                    allowResizeColumns: true,
                    allowEditObjects: true
                };
                json.sheets[sheetname].protectionOptions = option;
                json.sheets[sheetname].isProtected = false;
    
            });
            json.highlightInvalidData = false;
            let currentSheet = this.spread.getActiveSheet()
            let currentSheetname = currentSheet.name();
            currentSheetname = currentSheetname + '.xlsx';
            excelIo.save(json, function (blob: any) {
                FileSaver.saveAs(blob, currentSheetname);
            }, function (e: any) {
            });
  • Posted 13 February 2018, 10:50 pm EST

    Hello,

    You can set the width of the first two columns which you do not want to export to 0 before exporting to JSON or just hide them.

    Thanks,

    Deepak Sharma

Need extra support?

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

Learn More

Forum Channels