Posted 17 May 2021, 5:06 am EST
Dear support,
I’m reaching you out as I was looking at this implementation of a keyboard-driven fill (https://codesandbox.io/s/lucid-raman-1ydsm?file=/src/index.js:1488-1610) and I realised this code can’t be used as the rightFill command.
I wrote something similar to your snippet but it seems like the filled numbers are increasing by 1 which is not what happens when you right fill via dragging the little cross on the bottom-right corner with the pointer.
Please check this as reference:
const rightFill = {
canUndo: true,
execute: (wbContext, options, isUndo) => {
let Commands = GC.Spread.Sheets.Commands
if (isUndo) {
Commands.undoTransaction(wbContext, options)
return true
} else {
Commands.startTransaction(wbContext, options)
wbContext.suspendPaint()
let selections = wbContext.getActiveSheet().getSelections()
options.cmd = 'rightFill'
selections.forEach((sel) => {
let srange = new GC.Spread.Sheets.Range(sel.row, sel.col, sel.rowCount, 1)
let drange = new GC.Spread.Sheets.Range(sel.row, sel.col + 1, sel.rowCount, sel.colCount - 1)
wbContext.commandManager().execute({
cmd: 'fill',
sheetName: wbContext.getActiveSheet().name(),
startRange: srange,
fillRange: drange,
autoFillType: GC.Spread.Sheets.Fill.AutoFillType.fillSeries,
fillDirection: GC.Spread.Sheets.Fill.FillDirection.right,
})
})
wbContext.resumePaint()
Commands.endTransaction(wbContext, options)
return true
}
},
}
Looking forward to hearing from you