Posted 15 April 2020, 5:05 am EST
Code:
registerAddSpan() {
const command = {
canUndo: true,
canRedo: true,
execute: (
workbook: GC.Spread.Sheets.Workbook,
options: any,
isUndo: boolean
) => {
const Commands = GC.Spread.Sheets.Commands
const { sheet, sheetName, row, col, rowCount, colCount } = options
console.log(JSON.stringify(options.changesSheet2))
if (isUndo) {
Commands.undoTransaction(workbook, options)
this.emit(‘removeSpan’, {
sheet,
sheetName,
row,
col
})
return true
} else {
Commands.startTransaction(workbook, options)
sheet.addSpan(
row,
col,
rowCount,
colCount,
GC.Spread.Sheets.SheetArea.viewport
)
this.emit(‘addSpan’, {
sheet,
sheetName,
row,
col,
rowCount,
colCount
})
Commands.endTransaction(workbook, options)
return true
}
}
}
const cm = this.workbook.commandManager()
cm.register(‘addSpan’, command)
}
my sheetName is ‘Sheet2’,and do undo operation get
options.changesSheet2 = [[[“spanModels”,3,“spans”],],[[“selectionModel”,“selections”],[{“row”:1,“rowCount”:2,“col”:3,“colCount”:2}]],[[“selectionModel”,“activeSelectedRangeIndex”],0]]
how do I use the data to do removeSpan or tell the other people which span I need to remove.
I don’t know how to handle removeSpan .I hope get a event like rangeChanged event to handle undo .And if spans has A span between B span,How do I handle the removeSpan, becase removeSpan just has row,col without rowCount colCount
How to use commandManager emit DragMerged events. Also it can solve my problem.
Thanks again~