Posted 23 July 2019, 4:38 am EST
Hi is there any api available to set the position of the sheets.
Forums Home / Spread / SpreadJS
Posted by: datta on 23 July 2019, 4:38 am EST
Posted 23 July 2019, 4:38 am EST
Hi is there any api available to set the position of the sheets.
Posted 24 July 2019, 12:58 am EST
Hi,
We could move the position of the sheets in a workbook by accessing the workbook.sheets collection and using splice() method of the array. Please refer to the following code snippet and the sample demonstrating the same:
function moveSheetPosition(spread, curIndex, targetIndex) {
var list = spread.sheets,
activeSheet = spread.getActiveSheet().name();
if (targetIndex < 0 || targetIndex >= list.length) {
throw new Error("Invalid index error");
}
spread.suspendPaint();
list.splice(targetIndex, 0, list.splice(curIndex, 1)[0]);
spread.setActiveSheetIndex(spread.getSheetIndex(activeSheet));
spread.resumePaint();
}
https://codesandbox.io/s/spread-js-starter-14ke2
Regards