spread.commandManager().register("insertRowsBehind",
{
canUndo: true,
execute: function (context, options, isUndo) {
var Commands = GC.Spread.Sheets.Commands;
// 在此加cmd
options.cmd = "insertRowsBehind";
if (isUndo) {
Commands.undoTransaction(context, options);
return true;
} else {
var sheet = that.state.spread.getActiveSheet();
// 注意:需要在options中定义sheetName,否则撤销行为可能无效。
options.sheetName = sheet.name();
Commands.startTransaction(context, options);
var sels = sheet.getSelections();
if (sels && sels.length > 0) {
for (var i = 0; i < sels.length; i++) {
var sel = sels;
var row = sel.row;
var rowCount = sel.rowCount;
sheet.addRows(row + 1, rowCount);
}
let tables = sheet.tables.all()
for(let j in tables) {
console.log(tables[j].name())
let range = tables[j].range()
if(row>=range.row && row <= (range.row + range.rowCount - 1)){
debugger
sheet.tables.resize(tables[j], new GC.Spread.Sheets.Range(range.row,range.rowCount + rowCount + 10,range.col,range.colCount))
}
}
// sheet.copyTo(row + 1, 0, row, 0, 1, sheet.getColumnCount(), GC.Spread.Sheets.CopyToOptions.style);
}
Commands.endTransaction(context, options);
that.$store.dispatch('setsheetdisabled')
// that.$store.commit('setConfigByinsertcell',{
// type:'addRows',
// sheet:sheet,
// tag:sheet.tag(),
// row:row+1,
// count:sels
// })
return true;
}
}
});
|