Default Style

We provide two levels of default styles:

  1. The default style of the worksheet
  2. The default style of the column or row

Both can be set through the IWorksheetData interface or the Facade API.

Configuration

By default, the column style takes precedence over the row style. You can change this behavior by setting isRowStylePrecedeColumnStyle during registration.

TypeScript
univer.registerPlugin(UniverSheetsPlugin, {  isRowStylePrecedeColumnStyle: true,})

Set Default Style

There are two ways to set the default style of a worksheet:

  1. Through the IWorksheetData interface
TypeScript
interface IWorksheetData {  // other  /**   * @property {Nullable<IStyleData>} [defaultStyle] - Default style data of Worksheet.   */  defaultStyle?: Nullable<IStyleData>}interface IRowData {  // other  /**   * style data   */  s?: Nullable<IStyleData>}interface IColumnData {  // other  /**   * style data   */  s?: Nullable<IStyleData>}
  1. Set through the Facade API
TypeScript
const fworkbook = univerAPI.getActiveWorkbook()const fworksheet = fworkbook.getActiveSheet()const defaultStyle = {  bg: {    rgb: 'red',  },}const defaultColumnStyle = {  bg: {    rgb: 'blue',  },}const defaultRowStyle = {  bg: {    rgb: 'green',  },}// set default stylefworksheet.setDefaultStyle(defaultStyle)// set column D default stylefworksheet.setColumnDefaultStyle(3, defaultColumnStyle)// reset column D the default stylefworksheet.setColumnDefaultStyle(3, undefined)// set row default stylefworksheet.setRowDefaultStyle(1, defaultRowStyle)

Shrink text to fit

Use FRange to shrink text when it is wider than its cell. The setting applies to every cell in the range; getShrinkToFit() reads the top-left cell.

TypeScript
const range = univerAPI.getActiveWorkbook().getActiveSheet().getRange('A1:C3')range.setShrinkToFit(true)const enabled = range.getShrinkToFit()

How is this guide?

© 2026 DreamNum Co., Ltd.