Posted 6 May 2019, 6:01 am EST
Hi All,
Is there a way to exclude some sheets while exporting. For example assume that workbook has 2 sheets. When I export exported file should have only first sheet. Is there any option to specify sheets to exclude?
Forums Home / Spread / SpreadJS
Posted by: datta on 6 May 2019, 6:01 am EST
Posted 6 May 2019, 6:01 am EST
Hi All,
Is there a way to exclude some sheets while exporting. For example assume that workbook has 2 sheets. When I export exported file should have only first sheet. Is there any option to specify sheets to exclude?
Posted 7 May 2019, 12:45 am EST
Hi,
To exclude some sheets from the exported workbook what we could do is clone the current workbook and remove sheets from the cloned workbook and then export the cloned workbook.
Please refer to the following code snippet which demonstrates the same:
document.getElementById('saveExcel').onclick = function() {
var excelIo = new GC.Spread.Excel.IO();
var wbJSON = spread.toJSON({
includeBindingSource: true,
});
var clonedWb = new GC.Spread.Sheets.Workbook(document.createElement('div'));
clonedWb.fromJSON(wbJSON);
clonedWb.removeSheet(1); // remove Sheet2
var modifiedJSON = clonedWb.toJSON({
includeBindingSource: true,
});
clonedWb.destroy(); // dispose cloned workbook
excelIo.save(modifiedJSON, (blob) => {
saveAs(blob, 'sample.xlsx');
}, (e) => {
console.log(e);
});
}
Regards
Posted 8 May 2019, 3:10 am EST
OK Thanks I will try this. Can you tell me what ‘includeBindingSource’ is for? I could not find it in api dooc
Posted 9 May 2019, 4:34 am EST
‘includeBindingSource’ flag is used to indicate that we need to export the binding source too in case of bound sheets as well as table sources.
Please refer to the following document for a list of available serialization options:
http://help.grapecity.com/spread/SpreadSheets12/webframe.html#SpreadJS~GC.Spread.Sheets.Workbook~toJSON.html