Posted 31 July 2020, 1:41 pm EST
Hello,
Is SpreadJS able to programmatically insert cells or ranges of cells as opposed to entire rows/columns?
Forums Home / Spread / SpreadJS
Posted by: jeff.klotter on 31 July 2020, 1:41 pm EST
Posted 31 July 2020, 1:41 pm EST
Hello,
Is SpreadJS able to programmatically insert cells or ranges of cells as opposed to entire rows/columns?
Posted 5 August 2020, 3:54 am EST
Hi,
You may create a custom Command which insert Cells by shifting the range right or down like excel does. For shifting the cells you may use moveTo function. Please refer to the following code snippet and attached sample which demonstrates the same.
let sel = sheet.getSelections()[0];
switch (options.direction) {
case "right":
sheet.moveTo(
sel.row,
sel.col,
sel.row,
sel.col + sel.colCount,
sel.rowCount,
sheet.getColumnCount() - (sel.col + sel.colCount),
GC.Spread.Sheets.CopyToOptions.all
);
break;
case "down":
sheet.moveTo(
sel.row,
sel.col,
sel.row + sel.rowCount,
sel.col,
sheet.getRowCount() - (sel.row + sel.rowCount),
sel.colCount,
GC.Spread.Sheets.CopyToOptions.all
);
break;
default:
break;
}
sample: https://codesandbox.io/s/modest-poincare-obkg6?file=/src/index.js
API References:
• moveTo: https://www.grapecity.com/spreadjs/docs/v13/online/SpreadJS~GC.Spread.Sheets.Worksheet~moveTo.html
• customCommand: https://www.grapecity.com/spreadjs/demos/features/worksheet/actions/custom-action#demo_source_name
Regards
Posted 8 June 2022, 3:30 pm EST
Thanks for the help. Got it working.