Skip to content

Commit

Permalink
fix(formula): fix insert function of range has number value
Browse files Browse the repository at this point in the history
  • Loading branch information
wpxp123456 committed Jan 23, 2025
1 parent c997315 commit 2a367c4
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ export const InsertFunctionOperation: ICommand = {
if (startRow === endRow) {
// single row, insert function in the blank cell of the row
const blankCellColumn = findBlankCellOfRow(cellMatrix, startRow, endColumn, worksheet.getColumnCount() - 1);
const newEndColumn = blankCellColumn === endColumn ? endColumn - 1 : endColumn;
const rangeString = serializeRange({
startRow,
endRow,
startColumn,
endColumn: blankCellColumn - 1,
endColumn: newEndColumn,
});
const formulaString = `=${value}(${rangeString})`;

Expand All @@ -160,10 +161,12 @@ export const InsertFunctionOperation: ICommand = {
maxBlankCellRow = Math.max(maxBlankCellRow, blankCellRow);
}

const newEndRow = maxBlankCellRow === endRow ? endRow - 1 : endRow;

for (let c = startColumn; c <= endColumn; c++) {
const rangeString = serializeRange({
startRow,
endRow: maxBlankCellRow - 1,
endRow: newEndRow,
startColumn: c,
endColumn: c,
});
Expand Down

0 comments on commit 2a367c4

Please sign in to comment.