diff --git a/e2e/visual-comparison/sheets/sheets-gridlines.spec.ts b/e2e/visual-comparison/sheets/sheets-gridlines.spec.ts index 17a5eb283a3..19ce7edcaa4 100644 --- a/e2e/visual-comparison/sheets/sheets-gridlines.spec.ts +++ b/e2e/visual-comparison/sheets/sheets-gridlines.spec.ts @@ -32,7 +32,7 @@ test('sheets no gridlines', async () => { await page.waitForTimeout(2000); await page.evaluate(() => window.E2EControllerAPI.loadDefaultSheet()); await page.waitForTimeout(5000); - await page.evaluate(() => window.univerAPI.getActiveWorkbook().getActiveSheet().setGridlinesVisible(false)); + await page.evaluate(() => window.univerAPI.getActiveWorkbook().getActiveSheet().setHiddenGridlines(true)); await page.waitForTimeout(1000); const filename = generateSnapshotName('sheets-no-gridlines'); diff --git a/packages/facade/src/apis/sheets/f-worksheet.ts b/packages/facade/src/apis/sheets/f-worksheet.ts index 5dbd33ad3ac..e62fa9ec976 100644 --- a/packages/facade/src/apis/sheets/f-worksheet.ts +++ b/packages/facade/src/apis/sheets/f-worksheet.ts @@ -20,7 +20,7 @@ import type { IDataValidationResCache } from '@univerjs/sheets-data-validation'; import type { FilterModel } from '@univerjs/sheets-filter'; import type { FWorkbook, IFICanvasFloatDom } from './f-workbook'; -import { Direction, ICommandService, Inject, Injector, ObjectMatrix, RANGE_TYPE } from '@univerjs/core'; +import { BooleanNumber, Direction, ICommandService, Inject, Injector, ObjectMatrix, RANGE_TYPE } from '@univerjs/core'; import { DataValidationModel } from '@univerjs/data-validation'; import { deserializeRangeWithSheet } from '@univerjs/engine-formula'; import { copyRangeStyles, InsertColCommand, InsertRowCommand, MoveColsCommand, MoveRowsCommand, RemoveColCommand, RemoveRowCommand, SetColHiddenCommand, SetColWidthCommand, SetFrozenCommand, SetRangeValuesMutation, SetRowHeightCommand, SetRowHiddenCommand, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetWorksheetRowIsAutoHeightCommand, SheetsSelectionsService, ToggleGridlinesCommand } from '@univerjs/sheets'; @@ -1038,14 +1038,21 @@ export class FWorksheet { } /** - * Show or hide grid line. - * @param {boolean} visible If the grid line should be visible. + * Returns true if the sheet's gridlines are hidden; otherwise returns false. Gridlines are visible by default. */ - setGridlinesVisible(visible?: boolean): Promise { + hasHiddenGridLines(): boolean { + return this._worksheet.getConfig().showGridlines === BooleanNumber.FALSE; + } + + /** + * Hides or reveals the sheet gridlines. + * @param {boolean} hidden If `true`, hide gridlines in this sheet; otherwise show the gridlines. + */ + setHiddenGridlines(hidden: boolean): Promise { return this._commandService.executeCommand(ToggleGridlinesCommand.id, { unitId: this._workbook.getUnitId(), subUnitId: this._worksheet.getSheetId(), - showGridlines: visible, + showGridlines: hidden ? BooleanNumber.FALSE : BooleanNumber.TRUE, } as IToggleGridlinesCommandParams); }