Skip to content

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.

feat(facade): add getMaxColumns and getMaxRows API on FWorksheet (#1775)

FMWc90378045f0a
diff --git a/packages/facade/src/apis/__tests__/create-test-bed.ts b/packages/facade/src/apis/__tests__/create-test-bed.ts
index 91b6c3d7df..58240a018e 100644
--- a/packages/facade/src/apis/__tests__/create-test-bed.ts
+++ b/packages/facade/src/apis/__tests__/create-test-bed.ts
@@ -56,6 +56,8 @@ function getTestWorkbookDataDemo(): IWorkbookData {
id: 'sheet1',
name: 'sheet1',
cellData: {},
+ rowCount: 100,
+ columnCount: 100,
},
},
locale: LocaleType.ZH_CN,
diff --git a/packages/facade/src/apis/__tests__/facade.spec.ts b/packages/facade/src/apis/__tests__/facade.spec.ts
index 7387222a3d..a14d3d2d1d 100644
--- a/packages/facade/src/apis/__tests__/facade.spec.ts
+++ b/packages/facade/src/apis/__tests__/facade.spec.ts
@@ -213,4 +213,14 @@ describe('Test FUniver', () => {
const worksheet = univerAPI.getActiveWorkbook()?.getSheetBySheetId('sheet1');
expect(worksheet!.getSheetId()).toBe('sheet1');
});
+
+ it('Function getMaxColumns', () => {
+ const worksheet = univerAPI.getActiveWorkbook()?.getSheetBySheetId('sheet1');
+ expect(worksheet!.getMaxColumns()).toBe(100);
+ });
+
+ it('Function getMaxRows', () => {
+ const worksheet = univerAPI.getActiveWorkbook()?.getSheetBySheetId('sheet1');
+ expect(worksheet!.getMaxRows()).toBe(100);
+ });
});
diff --git a/packages/facade/src/apis/sheets/f-worksheet.ts b/packages/facade/src/apis/sheets/f-worksheet.ts
index dd538828e0..dfa0d48143 100644
--- a/packages/facade/src/apis/sheets/f-worksheet.ts
+++ b/packages/facade/src/apis/sheets/f-worksheet.ts
@@ -90,4 +90,20 @@ export class FWorksheet {
colWidth: width,
} as ISetWorksheetColWidthMutationParams);
}
+
+ /**
+ * Returns the current number of columns in the sheet, regardless of content.
+ * @return The maximum columns count of the sheet
+ */
+ getMaxColumns() {
+ return this._worksheet.getMaxColumns();
+ }
+
+ /**
+ * Returns the current number of rows in the sheet, regardless of content.
+ * @return The maximum rows count of the sheet
+ */
+ getMaxRows() {
+ return this._worksheet.getMaxRows();
+ }
}