Posted 17 October 2017, 1:28 pm EST
Hello,
I created a command for the 'fill" action and it’s working fine when the source range is filled with numbers.
But when the range has letters nothing is being filled.
For example, type letters a, b and c in A1, B1, C1 respectively, then select the three cells and finally drag with the cursor so the cells D1, E1 and F1 are fill with a, b, c.
Nothing is happening when using my custom implementation for fill command.
Here is my fill command implementation:
export default class FillCommand {
register(commandManager) {
commandManager.register(‘fill’, {
canUndo: true,
execute: (context, options, isUndo) => {
context.suspendPaint();
context.suspendCalcService(false);
context.suspendEvent();
if (isUndo) { this.undo(options); } else { this.do(context, options); } context.resumeEvent(); context.resumeCalcService(false); context.resumePaint(); }, });
}
do(context, options) {
if (!options.sheet) {
this.saveCurrentState(context, options);
}
let wholeRange;
let fillSeries;
if (options.fillDirection === 0 || options.fillDirection === 1) { wholeRange = new GC.Spread.Sheets.Range( options.startRange.row, options.startRange.col, options.fillRange.rowCount, options.startRange.colCount + options.fillRange.colCount); fillSeries = GC.Spread.Sheets.Fill.FillSeries.row; } else { wholeRange = new GC.Spread.Sheets.Range( options.startRange.row, options.startRange.col, options.startRange.rowCount + options.fillRange.rowCount, options.fillRange.colCount); fillSeries = GC.Spread.Sheets.Fill.FillSeries.column; } options.sheet.setSelection(wholeRange.row, wholeRange.col, wholeRange.rowCount, wholeRange.colCount); options.sheet.fillAuto(options.startRange, wholeRange, { series: fillSeries, fillType: options.autoFillType, direction: options.fillDirection, });
}
undo(options) {
options.sheet.setArray(
options.previousState.row,
options.previousState.col,
options.previousState.range,
false
);
}
saveCurrentState(context, options) {
options.sheet = context.getActiveSheet();
options.previousState = {
row: options.fillRange.row,
col: options.fillRange.col,
range: options.sheet.getArray(
options.fillRange.row,
options.fillRange.col,
options.fillRange.rowCount,
options.fillRange.colCount
),
};
}
}
I’ll appreciate any comment that let me fix the issue.
Román