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 customizeColumnHeader and customizeRowHeader api (#5460)
wpxp12345658de0a4614ad
diff --git a/packages/engine-render/src/components/sheets/column-header.ts b/packages/engine-render/src/components/sheets/column-header.tsindex 0fe1fd74cd..11defb06a2 100644--- a/packages/engine-render/src/components/sheets/column-header.ts+++ b/packages/engine-render/src/components/sheets/column-header.ts@@ -96,8 +96,8 @@ export class SpreadsheetColumnHeader extends SpreadsheetHeader {* Customize column header, such as custom header text and background.* @param cfg*/- setCustomHeader(cfg: IColumnsHeaderCfgParam): void {+ setCustomHeader(cfg: IColumnsHeaderCfgParam, sheetId?: string): void {this.makeDirty(true);- this._columnHeaderLayoutExtension.configHeaderColumn(cfg);+ this._columnHeaderLayoutExtension.configHeaderColumn(cfg, sheetId);}}diff --git a/packages/engine-render/src/components/sheets/extensions/column-header-layout.ts b/packages/engine-render/src/components/sheets/extensions/column-header-layout.tsindex 4e02353e9e..d64e63b655 100644--- a/packages/engine-render/src/components/sheets/extensions/column-header-layout.ts+++ b/packages/engine-render/src/components/sheets/extensions/column-header-layout.ts@@ -16,7 +16,6 @@import type { IScale } from '@univerjs/core';import type { UniverRenderingContext } from '../../../context';-import type { IAColumnCfg, IAColumnCfgObj, IHeaderStyleCfg } from '../interfaces';import type { SpreadsheetSkeleton } from '../sheet.render-skeleton';import { numberToABC } from '@univerjs/core';@@ -26,10 +25,12 @@ import { SheetColumnHeaderExtensionRegistry } from '../../extension';import { SheetExtension } from './sheet-extension';const UNIQUE_KEY = 'DefaultColumnHeaderLayoutExtension';+export interface IColumnsHeaderCfgParam {headerStyle?: Partial<IHeaderStyleCfg>;- columnsCfg?: IAColumnCfg[];+ columnsCfg?: Record<number, IAColumnCfg>;}+const DEFAULT_COLUMN_STYLE = {fontSize: 13,fontFamily: DEFAULT_FONTFACE_PLANE,@@ -46,16 +47,12 @@ const DEFAULT_COLUMN_STYLE = {export class ColumnHeaderLayout extends SheetExtension {override uKey = UNIQUE_KEY;override Z_INDEX = 10;- columnsCfg: IAColumnCfg[] = [];- headerStyle: IHeaderStyleCfg = {- fontSize: DEFAULT_COLUMN_STYLE.fontSize,- fontFamily: DEFAULT_COLUMN_STYLE.fontFamily,- fontColor: DEFAULT_COLUMN_STYLE.fontColor,- backgroundColor: DEFAULT_COLUMN_STYLE.backgroundColor,- borderColor: DEFAULT_COLUMN_STYLE.borderColor,- textAlign: DEFAULT_COLUMN_STYLE.textAlign,- textBaseline: DEFAULT_COLUMN_STYLE.textBaseline,- };+ // The workbook columns configuration and header style+ columnsCfg: Record<number, IAColumnCfg> = {};+ headerStyle: Partial<IHeaderStyleCfg> = {};+ // Map of column configurations and header styles for each worksheet, where the key is worksheet id+ columnsCfgOfWorksheet: Map<string, Record<number, IAColumnCfg>> = new Map();+ headerStyleOfWorksheet: Map<string, Partial<IHeaderStyleCfg>> = new Map();constructor(cfg?: IColumnsHeaderCfgParam) {super();@@ -64,24 +61,38 @@ export class ColumnHeaderLayout extends SheetExtension {}}- configHeaderColumn(cfg: IColumnsHeaderCfgParam): void {- this.columnsCfg = cfg.columnsCfg || [];- this.headerStyle = { ...this.headerStyle, ...cfg.headerStyle };+ configHeaderColumn(cfg: IColumnsHeaderCfgParam, sheetId?: string): void {+ if (sheetId) {+ this.columnsCfgOfWorksheet.set(sheetId, cfg.columnsCfg ?? {});+ this.headerStyleOfWorksheet.set(sheetId, cfg.headerStyle ?? {});+ } else {+ this.columnsCfg = cfg.columnsCfg ?? {};+ this.headerStyle = cfg.headerStyle ?? {};+ }+ }++ getColumnsCfg(sheetId: string): Record<number, IAColumnCfg> {+ const columnsCfg = this.columnsCfgOfWorksheet.get(sheetId) ?? {};+ return { ...this.columnsCfg, ...columnsCfg };}- getCfgOfCurrentColumn(colIndex: number): [IAColumnCfgObj, boolean] {+ getHeaderStyle(sheetId: string): IHeaderStyleCfg {+ const headerStyle = this.headerStyleOfWorksheet.get(sheetId) ?? {};+ return { ...DEFAULT_COLUMN_STYLE, ...this.headerStyle, ...headerStyle };+ }++ getCfgOfCurrentColumn(columnsCfg: Record<number, IAColumnCfg>, headerStyle: IHeaderStyleCfg, colIndex: number): [IAColumnCfgObj, boolean] {let mergeWithSpecCfg;let curColSpecCfg;- const columnsCfg = this.columnsCfg || [];if (columnsCfg[colIndex]) {if (typeof columnsCfg[colIndex] == 'string') {columnsCfg[colIndex] = { text: columnsCfg[colIndex] } as IAColumnCfgObj;}curColSpecCfg = columnsCfg[colIndex] as IHeaderStyleCfg & { text: string };- mergeWithSpecCfg = { ...this.headerStyle, ...curColSpecCfg };+ mergeWithSpecCfg = { ...headerStyle, ...curColSpecCfg };} else {- mergeWithSpecCfg = { ...this.headerStyle, text: numberToABC(colIndex) };+ mergeWithSpecCfg = { ...headerStyle, text: numberToABC(colIndex) };}const specStyle = Object.keys(curColSpecCfg || {}).length > 1; // if cfg have more keys than 'text', means there would be special style config for this column.return [mergeWithSpecCfg, specStyle] as [IAColumnCfgObj, boolean];@@ -104,7 +115,7 @@ export class ColumnHeaderLayout extends SheetExtension {return;}- const { rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight } = spreadsheetSkeleton;+ const { rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight, worksheet } = spreadsheetSkeleton;if (!rowHeightAccumulation ||@@ -115,12 +126,15 @@ export class ColumnHeaderLayout extends SheetExtension {return;}+ const columnsCfg = this.getColumnsCfg(worksheet.getSheetId());+ const headerStyle = this.getHeaderStyle(worksheet.getSheetId());+const scale = this._getScale(parentScale);- this.setStyleToCtx(ctx, this.headerStyle);+ this.setStyleToCtx(ctx, headerStyle);// backgroundctx.save();- ctx.fillStyle = this.headerStyle.backgroundColor;+ ctx.fillStyle = headerStyle.backgroundColor;ctx.fillRectByPrecision(0, 0, columnTotalWidth, columnHeaderHeight);ctx.restore();@@ -139,7 +153,7 @@ export class ColumnHeaderLayout extends SheetExtension {continue;// Skip hidden columns}const cellBound = { left: preColumnPosition, top: 0, right: columnEndPosition, bottom: columnHeaderHeight, width: columnEndPosition - preColumnPosition, height: columnHeaderHeight };- const [curColumnCfg, specStyle] = this.getCfgOfCurrentColumn(c);+ const [curColumnCfg, specStyle] = this.getCfgOfCurrentColumn(columnsCfg, headerStyle, c);// backgroundif (specStyle && curColumnCfg.backgroundColor) {diff --git a/packages/engine-render/src/components/sheets/extensions/row-header-layout.ts b/packages/engine-render/src/components/sheets/extensions/row-header-layout.tsindex 7d9334b58f..1e8c12a99f 100644--- a/packages/engine-render/src/components/sheets/extensions/row-header-layout.ts+++ b/packages/engine-render/src/components/sheets/extensions/row-header-layout.ts@@ -15,7 +15,6 @@*/import type { IScale } from '@univerjs/core';-import type { UniverRenderingContext } from '../../../context';import type { IARowCfg, IARowCfgObj, IHeaderStyleCfg, IRowStyleCfg } from '../interfaces';import type { SpreadsheetSkeleton } from '../sheet.render-skeleton';@@ -28,7 +27,7 @@ const UNIQUE_KEY = 'DefaultRowHeaderLayoutExtension';export interface IRowsHeaderCfgParam {headerStyle?: Partial<IRowStyleCfg>;- rowsCfg?: IARowCfg[];+ rowsCfg?: Record<number, IARowCfg>;}const DEFAULT_ROW_STYLE = {@@ -44,16 +43,12 @@ const DEFAULT_ROW_STYLE = {export class RowHeaderLayout extends SheetExtension {override uKey = UNIQUE_KEY;override Z_INDEX = 10;- rowsCfg: IARowCfg[] = [];- headerStyle: IRowStyleCfg = {- fontSize: DEFAULT_ROW_STYLE.fontSize,- fontFamily: DEFAULT_ROW_STYLE.fontFamily,- fontColor: DEFAULT_ROW_STYLE.fontColor,- backgroundColor: DEFAULT_ROW_STYLE.backgroundColor,- borderColor: DEFAULT_ROW_STYLE.borderColor,- textAlign: DEFAULT_ROW_STYLE.textAlign,- textBaseline: DEFAULT_ROW_STYLE.textBaseline,- };+ // The workbook rows configuration and header style+ rowsCfg: Record<number, IARowCfg> = {};+ headerStyle: Partial<IRowStyleCfg> = {};+ // Map of row configurations and header styles for each worksheet, where the key is worksheet id+ rowsCfgOfWorksheet: Map<string, Record<number, IARowCfg>> = new Map();+ headerStyleOfWorksheet: Map<string, Partial<IRowStyleCfg>> = new Map();constructor(cfg?: IRowsHeaderCfgParam) {super();@@ -62,24 +57,38 @@ export class RowHeaderLayout extends SheetExtension {}}- configHeaderRow(cfg: IRowsHeaderCfgParam) {- this.rowsCfg = cfg.rowsCfg || [];- this.headerStyle = { ...this.headerStyle, ...cfg.headerStyle };+ configHeaderRow(cfg: IRowsHeaderCfgParam, sheetId?: string) {+ if (sheetId) {+ this.rowsCfgOfWorksheet.set(sheetId, cfg.rowsCfg ?? {});+ this.headerStyleOfWorksheet.set(sheetId, cfg.headerStyle ?? {});+ } else {+ this.rowsCfg = cfg.rowsCfg ?? {};+ this.headerStyle = cfg.headerStyle ?? {};+ }+ }++ getRowsCfg(sheetId: string): Record<number, IARowCfg> {+ const rowsCfg = this.rowsCfgOfWorksheet.get(sheetId) ?? {};+ return { ...this.rowsCfg, ...rowsCfg };+ }++ getHeaderStyle(sheetId: string): IRowStyleCfg {+ const headerStyle = this.headerStyleOfWorksheet.get(sheetId) ?? {};+ return { ...DEFAULT_ROW_STYLE, ...this.headerStyle, ...headerStyle };}- getCfgOfCurrentRow(rowIndex: number) {+ getCfgOfCurrentRow(rowsCfg: Record<number, IARowCfg>, headerStyle: IHeaderStyleCfg, rowIndex: number) {let mergeWithSpecCfg;let curRowSpecCfg;- const rowsCfg = this.rowsCfg || [];if (rowsCfg[rowIndex]) {if (typeof rowsCfg[rowIndex] == 'string') {rowsCfg[rowIndex] = { text: rowsCfg[rowIndex] } as IARowCfgObj;}curRowSpecCfg = rowsCfg[rowIndex] as IRowStyleCfg & { text: string };- mergeWithSpecCfg = { ...this.headerStyle, ...curRowSpecCfg };+ mergeWithSpecCfg = { ...headerStyle, ...curRowSpecCfg };} else {- mergeWithSpecCfg = { ...this.headerStyle, text: `${rowIndex + 1}` };+ mergeWithSpecCfg = { ...headerStyle, text: `${rowIndex + 1}` };}const specStyle = Object.keys(curRowSpecCfg || {}).length > 1; // if cfg have more keys than 'text', means there would be special style config for this row.return [mergeWithSpecCfg, specStyle] as [IARowCfgObj, boolean];@@ -102,7 +111,7 @@ export class RowHeaderLayout extends SheetExtension {return;}- const { rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight } =+ const { rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight, worksheet } =spreadsheetSkeleton;if (@@ -114,12 +123,15 @@ export class RowHeaderLayout extends SheetExtension {return;}+ const rowsCfg = this.getRowsCfg(worksheet.getSheetId());+ const headerStyle = this.getHeaderStyle(worksheet.getSheetId());+const scale = this._getScale(parentScale);- this.setStyleToCtx(ctx, this.headerStyle);+ this.setStyleToCtx(ctx, headerStyle);// backgroundctx.save();- ctx.fillStyle = this.headerStyle.backgroundColor;+ ctx.fillStyle = headerStyle.backgroundColor;ctx.fillRectByPrecision(0, 0, rowHeaderWidth, rowTotalHeight);ctx.restore();@@ -144,7 +156,7 @@ export class RowHeaderLayout extends SheetExtension {width: rowHeaderWidth,height: rowEndPosition - preRowPosition,};- const [curRowCfg, specStyle] = this.getCfgOfCurrentRow(r);+ const [curRowCfg, specStyle] = this.getCfgOfCurrentRow(rowsCfg, headerStyle, r);// backgroundif (specStyle && curRowCfg.backgroundColor) {diff --git a/packages/engine-render/src/components/sheets/row-header.ts b/packages/engine-render/src/components/sheets/row-header.tsindex 7d1864f910..32b2a0fd0c 100644--- a/packages/engine-render/src/components/sheets/row-header.ts+++ b/packages/engine-render/src/components/sheets/row-header.ts@@ -102,8 +102,8 @@ export class SpreadsheetRowHeader extends SpreadsheetHeader {this._rowHeaderLayoutExtension = this.getExtensionByKey('DefaultRowHeaderLayoutExtension') as RowHeaderLayout;}- setCustomHeader(cfg: IRowsHeaderCfgParam) {+ setCustomHeader(cfg: IRowsHeaderCfgParam, sheetId?: string) {this.makeDirty(true);- this._rowHeaderLayoutExtension.configHeaderRow(cfg);+ this._rowHeaderLayoutExtension.configHeaderRow(cfg, sheetId);}}diff --git a/packages/sheets-ui/src/commands/commands/headersize-changed.command.ts b/packages/sheets-ui/src/commands/commands/headersize-changed.command.tsindex 64b96ad7b4..124e1c3cb6 100644--- a/packages/sheets-ui/src/commands/commands/headersize-changed.command.ts+++ b/packages/sheets-ui/src/commands/commands/headersize-changed.command.ts@@ -49,7 +49,7 @@ export const SetRowHeaderWidthCommand: ICommand<ISetHeaderSizeParams> = {const { components } = render;const renderComponent = components.get(SHEET_VIEW_KEY.ROW);if (renderComponent) {- (renderComponent as SpreadsheetRowHeader).setCustomHeader({ headerStyle: { size } });+ (renderComponent as SpreadsheetRowHeader).setCustomHeader({ headerStyle: { size } }, subUnitId);}}@@ -77,7 +77,7 @@ export const SetColumnHeaderHeightCommand: ICommand<ISetHeaderSizeParams> = {const { components } = render;const renderComponent = components.get(SHEET_VIEW_KEY.COLUMN);if (renderComponent) {- (renderComponent as SpreadsheetColumnHeader).setCustomHeader({ headerStyle: { size } });+ (renderComponent as SpreadsheetColumnHeader).setCustomHeader({ headerStyle: { size } }, subUnitId);}}diff --git a/packages/sheets-ui/src/facade/f-univer.ts b/packages/sheets-ui/src/facade/f-univer.tsindex 2ce2c30b03..20fe67c5e3 100644--- a/packages/sheets-ui/src/facade/f-univer.ts+++ b/packages/sheets-ui/src/facade/f-univer.ts@@ -45,24 +45,12 @@ import { combineLatest, filter } from 'rxjs';*/export interface IFUniverSheetsUIMixin {/**- * @deprecated use same API in FWorkSheet.- * Customize the column header of the spreadsheet.- * @param {IColumnsHeaderCfgParam} cfg The configuration of the column header.- * @example- * ```typescript- * univerAPI.customizeColumnHeader({ headerStyle: { fontColor: '#fff', size: 40, backgroundColor: '#4e69ee', fontSize: 9 }, columnsCfg: ['MokaII', undefined, null, { text: 'Size', textAlign: 'left' }] });- * ```+ * @deprecated use same API in FWorkbook and FWorkSheet.*/customizeColumnHeader(cfg: IColumnsHeaderCfgParam): void;/**- * @deprecated use same API in FWorkSheet.- * Customize the row header of the spreadsheet.- * @param {IRowsHeaderCfgParam} cfg The configuration of the row header.- * @example- * ```typescript- * univerAPI.customizeRowHeader({ headerStyle: { backgroundColor: 'pink', fontSize: 9 }, rowsCfg: ['MokaII', undefined, null, { text: 'Size', textAlign: 'left' }] });- * ```+ * @deprecated use same API in FWorkbook and FWorkSheet.*/customizeRowHeader(cfg: IRowsHeaderCfgParam): void;diff --git a/packages/sheets-ui/src/facade/f-workbook.ts b/packages/sheets-ui/src/facade/f-workbook.tsindex 5f39ef13b7..12a16958b5 100644--- a/packages/sheets-ui/src/facade/f-workbook.ts+++ b/packages/sheets-ui/src/facade/f-workbook.ts@@ -15,14 +15,14 @@*/import type { IDisposable, Nullable } from '@univerjs/core';-import type { IMouseEvent, IPointerEvent, RenderManagerService } from '@univerjs/engine-render';+import type { IColumnsHeaderCfgParam, IMouseEvent, IPointerEvent, IRowsHeaderCfgParam, RenderComponentType, RenderManagerService, SpreadsheetColumnHeader, SpreadsheetRowHeader } from '@univerjs/engine-render';import type { ICellPosWithEvent, IDragCellPosition, IEditorBridgeServiceVisibleParam, IHoverRichTextInfo, IHoverRichTextPosition, IScrollState, SheetSelectionRenderService } from '@univerjs/sheets-ui';-import type { IDialogPartMethodOptions, ISidebarMethodOptions } from '@univerjs/ui';+import type { ICellEventParam } from './f-event';import { awaitTime, ICommandService, ILogService, toDisposable } from '@univerjs/core';import { DeviceInputEventType, IRenderManagerService } from '@univerjs/engine-render';-import { DragManagerService, HoverManagerService, ISheetSelectionRenderService, SetCellEditVisibleOperation, SheetScrollManagerService } from '@univerjs/sheets-ui';+import { DragManagerService, HoverManagerService, ISheetSelectionRenderService, SetCellEditVisibleOperation, SHEET_VIEW_KEY, SheetScrollManagerService } from '@univerjs/sheets-ui';import { FWorkbook } from '@univerjs/sheets/facade';import { IDialogService, ISidebarService, KeyCode } from '@univerjs/ui';import { filter } from 'rxjs';@@ -92,6 +92,58 @@ export interface IFWorkbookSheetsUIMixin {*/openDialog(dialog: IDialogPartMethodOptions): IDisposable;+ /**+ * Customize the column header of the all worksheets in the workbook.+ * @param {IColumnsHeaderCfgParam} cfg The configuration of the column header.+ * @example+ * ```typescript+ * const fWorkbook = univerAPI.getActiveWorkbook();+ * fWorkbook.customizeColumnHeader({+ * headerStyle: {+ * fontColor: '#fff',+ * backgroundColor: '#4e69ee',+ * fontSize: 9+ * },+ * columnsCfg: {+ * 0: 'kuma II',+ * 3: {+ * text: 'Size',+ * textAlign: 'left', // CanvasTextAlign+ * fontColor: '#fff',+ * fontSize: 12,+ * borderColor: 'pink',+ * backgroundColor: 'pink',+ * },+ * 4: 'Wow'+ * }+ * });+ * ```+ */+ customizeColumnHeader(cfg: IColumnsHeaderCfgParam): void;++ /**+ * Customize the row header of the all worksheets in the workbook.+ * @param {IRowsHeaderCfgParam} cfg The configuration of the row header.+ * @example+ * ```typescript+ * const fWorkbook = univerAPI.getActiveWorkbook();+ * fWorkbook.customizeRowHeader({+ * headerStyle: {+ * backgroundColor: 'pink',+ * fontSize: 12+ * },+ * rowsCfg: {+ * 0: 'Moka II',+ * 3: {+ * text: 'Size',+ * textAlign: 'left', // CanvasTextAlign+ * },+ * }+ * });+ * ```+ */+ customizeRowHeader(cfg: IRowsHeaderCfgParam): void;+/*** @deprecated use `univerAPI.addEvent(univerAPI.Event.CellClicked, (params) => {})` instead*/@@ -255,6 +307,41 @@ export class FWorkbookSheetsUIMixin extends FWorkbook implements IFWorkbookSheetreturn disposable;}+ override customizeColumnHeader(cfg: IColumnsHeaderCfgParam): void {+ const unitId = this._workbook.getUnitId();+ const sheetColumn = this._getSheetRenderComponent(unitId, SHEET_VIEW_KEY.COLUMN) as SpreadsheetColumnHeader;+ sheetColumn.setCustomHeader(cfg);+ }++ override customizeRowHeader(cfg: IRowsHeaderCfgParam): void {+ const unitId = this._workbook.getUnitId();+ const sheetRow = this._getSheetRenderComponent(unitId, SHEET_VIEW_KEY.ROW) as SpreadsheetRowHeader;+ sheetRow.setCustomHeader(cfg);+ }++ /**+ * Get sheet render component from render by unitId and view key.+ * @private+ * @param {string} unitId The unit id of the spreadsheet.+ * @param {SHEET_VIEW_KEY} viewKey The view key of the spreadsheet.+ * @returns {Nullable<RenderComponentType>} The render component.+ */+ private _getSheetRenderComponent(unitId: string, viewKey: SHEET_VIEW_KEY): Nullable<RenderComponentType> {+ const renderManagerService = this._injector.get(IRenderManagerService);+ const render = renderManagerService.getRenderById(unitId);+ if (!render) {+ throw new Error(`Render Unit with unitId ${unitId} not found`);+ }++ const { components } = render;+ const renderComponent = components.get(viewKey);+ if (!renderComponent) {+ throw new Error('Render component not found');+ }++ return renderComponent;+ }+private _logDeprecation(name: string): void {const logService = this._injector.get(ILogService);diff --git a/packages/sheets-ui/src/facade/f-worksheet.ts b/packages/sheets-ui/src/facade/f-worksheet.tsindex 1e20cda230..499b859c56 100644--- a/packages/sheets-ui/src/facade/f-worksheet.ts+++ b/packages/sheets-ui/src/facade/f-worksheet.ts@@ -200,53 +200,55 @@ export interface IFWorksheetSkeletonMixin {autoResizeRows(startRow: number, numRows: number): FWorksheet;/**- * Customize the column header of the spreadsheet.+ * Customize the column header of the worksheet.* @param {IColumnsHeaderCfgParam} cfg The configuration of the column header.* @example* ```typescript- const fWorkbook = univerAPI.getActiveWorkbook();- const fWorksheet = fWorkbook.getActiveSheet();- fWorksheet.customizeColumnHeader({- headerStyle: {- fontColor: '#fff',- backgroundColor: '#4e69ee',- fontSize: 9- },- columnsCfg: {- 0: 'kuma II',- 3: {- text: 'Size',- textAlign: 'left', // CanvasTextAlign- fontColor: '#fff',- fontSize: 12,- borderColor: 'pink',- backgroundColor: 'pink',- },- 4: 'Wow'- }- });+ * const fWorkbook = univerAPI.getActiveWorkbook();+ * const fWorksheet = fWorkbook.getActiveSheet();+ * fWorksheet.customizeColumnHeader({+ * headerStyle: {+ * fontColor: '#fff',+ * backgroundColor: '#4e69ee',+ * fontSize: 9+ * },+ * columnsCfg: {+ * 0: 'kuma II',+ * 3: {+ * text: 'Size',+ * textAlign: 'left', // CanvasTextAlign+ * fontColor: '#fff',+ * fontSize: 12,+ * borderColor: 'pink',+ * backgroundColor: 'pink',+ * },+ * 4: 'Wow'+ * }+ * });* ```*/customizeColumnHeader(cfg: IColumnsHeaderCfgParam): void;/**- * Customize the row header of the spreadsheet.+ * Customize the row header of the worksheet.* @param {IRowsHeaderCfgParam} cfg The configuration of the row header.* @example* ```typescript- univerAPI.customizeRowHeader({- headerStyle: {- backgroundColor: 'pink',- fontSize: 12- },- rowsCfg: {- 0: 'MokaII',- 3: {- text: 'Size',- textAlign: 'left'- }- }- });+ * const fWorkbook = univerAPI.getActiveWorkbook();+ * const fWorksheet = fWorkbook.getActiveSheet();+ * fWorksheet.customizeRowHeader({+ * headerStyle: {+ * backgroundColor: 'pink',+ * fontSize: 12+ * },+ * rowsCfg: {+ * 0: 'Moka II',+ * 3: {+ * text: 'Size',+ * textAlign: 'left', // CanvasTextAlign+ * },+ * }+ * });* ```*/customizeRowHeader(cfg: IRowsHeaderCfgParam): void;@@ -447,61 +449,56 @@ export class FWorksheetSkeletonMixin extends FWorksheet implements IFWorksheetSk}override customizeColumnHeader(cfg: IColumnsHeaderCfgParam): void {- const activeSheet = this;- const unitId = this._fWorkbook.getId();+ const unitId = this._workbook.getUnitId();+ const subUnitId = this._worksheet.getSheetId();+const renderManagerService = this._injector.get(IRenderManagerService);- const subUnitId = activeSheet.getSheetId();const render = renderManagerService.getRenderById(unitId);if (render && cfg.headerStyle?.size) {const skm = render.with(SheetSkeletonManagerService);skm.setColumnHeaderSize(render, subUnitId, cfg.headerStyle?.size);- activeSheet?.refreshCanvas();}const sheetColumn = this._getSheetRenderComponent(unitId, SHEET_VIEW_KEY.COLUMN) as SpreadsheetColumnHeader;- if (sheetColumn) {- sheetColumn.setCustomHeader(cfg);- activeSheet?.refreshCanvas();- }+ sheetColumn.setCustomHeader(cfg, subUnitId);}override customizeRowHeader(cfg: IRowsHeaderCfgParam): void {- const unitId = this._fWorkbook.getId();+ const unitId = this._workbook.getUnitId();+ const subUnitId = this._worksheet.getSheetId();++ const renderManagerService = this._injector.get(IRenderManagerService);+ const render = renderManagerService.getRenderById(unitId);+ if (render && cfg.headerStyle?.size) {+ const skm = render.with(SheetSkeletonManagerService);+ skm.setRowHeaderSize(render, subUnitId, cfg.headerStyle?.size);+ }+const sheetRow = this._getSheetRenderComponent(unitId, SHEET_VIEW_KEY.ROW) as SpreadsheetRowHeader;- sheetRow.setCustomHeader(cfg);+ sheetRow.setCustomHeader(cfg, subUnitId);}override setColumnHeaderHeight(height: number): FWorksheet {- const activeSheet = this;- const unitId = this._fWorkbook.getId();- const subUnitId = activeSheet.getSheetId();+ const unitId = this._workbook.getUnitId();+ const subUnitId = this._worksheet.getSheetId();this._commandService.executeCommand(SetColumnHeaderHeightCommand.id, {unitId,subUnitId,size: height,});-- activeSheet?.refreshCanvas();return this;}override setRowHeaderWidth(width: number): FWorksheet {- const activeSheet = this;- const unitId = this._fWorkbook.getId();- const subUnitId = activeSheet.getSheetId();+ const unitId = this._workbook.getUnitId();+ const subUnitId = this._worksheet.getSheetId();this._commandService.executeCommand(SetRowHeaderWidthCommand.id, {unitId,subUnitId,size: width,});-- const sheetRow = this._getSheetRenderComponent(unitId, SHEET_VIEW_KEY.ROW) as SpreadsheetRowHeader;- if (sheetRow) {- sheetRow.setCustomHeader({ headerStyle: { size: width } });- }- activeSheet?.refreshCanvas();return this;}