Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(facade): fix the issue that setNumberFormat API setting for empty cells is invalid (#6025)
wpxp12345637fefa6a8d01
diff --git a/packages/sheets-numfmt/src/facade/f-range.ts b/packages/sheets-numfmt/src/facade/f-range.tsindex 7f19f9da9a..3069df9163 100644--- a/packages/sheets-numfmt/src/facade/f-range.ts+++ b/packages/sheets-numfmt/src/facade/f-range.ts@@ -101,7 +101,13 @@ export class FRangeLegacy extends FRange implements IFRangeSheetsNumfmtMixin {const values: ISetNumfmtCommandParams['values'] = [];// Add number format info to the `values` array.- this.forEach((row, col) => values.push({ row, col, pattern }));+ const { startColumn, startRow, endColumn, endRow } = this._range;+ for (let row = startRow; row <= endRow; row++) {+ for (let col = startColumn; col <= endColumn; col++) {+ values.push({ row, col, pattern });+ }+ }+this._commandService.syncExecuteCommand(SetNumfmtCommand.id, {unitId: this._workbook.getUnitId(),subUnitId: this._worksheet.getSheetId(),@@ -115,10 +121,14 @@ export class FRangeLegacy extends FRange implements IFRangeSheetsNumfmtMixin {const values: ISetNumfmtCommandParams['values'] = [];// Add number format info to the `values` array.- this.forEach((row, col) => {- const pattern = patterns[row]?.[col];- values.push({ row, col, pattern });- });+ const { startColumn, startRow, endColumn, endRow } = this._range;+ for (let row = startRow; row <= endRow; row++) {+ for (let col = startColumn; col <= endColumn; col++) {+ const pattern = patterns[row - startRow]?.[col - startColumn];+ values.push({ row, col, pattern });+ }+ }+this._commandService.syncExecuteCommand(SetNumfmtCommand.id, {unitId: this._workbook.getUnitId(),subUnitId: this._worksheet.getSheetId(),