Number Format

Number formats control how a number appears in a cell. The format determines the number of decimal places, whether thousands separators are used, and whether the value is shown as a percentage or with a currency symbol, among other options. Once a format is set, the data is easier to read.

The currency action in the toolbar takes its currency symbol and pattern from Univer's region. If region is not configured explicitly, it follows locale:

TypeScript
const univer = new Univer({  locale: LocaleType.EN_US,  region: LocaleType.DE_DE,})

Caution

DBNum syntax is not supported.

Number format explorer

Change the value, format, or locale. Formatting changes the display, not the stored number.

Displayed value

1,234.57

Stored value: 1234.567

Try 0.25 as a percentage, or 45658 as a date.

Usage

In the UI, set a cell's number format from the menu bar. In code, set the s.n.pattern1 field of the cell's ICellData object.

TypeScript
const data = {  v: 123456.789,  s: {    n: {      pattern: '#,##0.00',    },  },}

By default, text that starts with 0 and numbers that can be interpreted as dates are converted to the corresponding number format automatically.

To prevent the automatic conversion, use one of the following two options:

  1. Set the number format of the cell to text.
TypeScript
import { DEFAULT_TEXT_FORMAT_EXCEL } from '@univerjs/core'const data = {  v: '012.0',  s: {    n: {      pattern: DEFAULT_TEXT_FORMAT_EXCEL, // Text format    },  },}

The format can also be set through the Facade API:

TypeScript
fRange.setNumberFormat(DEFAULT_TEXT_FORMAT_EXCEL)
  1. Type a single quote ' before the number. This is called forcing text.

UniverSheetsNumfmtPlugin provides two options, disableTextFormatAlert and disableTextFormatMark, to disable the warning and the marker for cells formatted as text.

Merge these options into the existing initialization for the integration mode in use. Keep the other plugin, locale, theme, and container settings, and do not register the same plugin twice.

Number parsing and decimal places

Accounting notation is read as a number: =VALUE("(5)") returns -5, and (1,000) or ($1,000) becomes -1000. Increase and Decrease Decimal change only the numeric sections of a format, so date and time patterns keep their digits.

Plugin configuration

UniverSheetsNumfmtPlugin

  • disableTextFormatAlert
    booleanDefault: false
    Disables the text format warning.
  • disableTextFormatMark
    booleanDefault: false
    Disables the text format marker.
TypeScript
import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt'univer.registerPlugin(UniverSheetsNumfmtPlugin, {  disableTextFormatAlert: true,  disableTextFormatMark: true,})

Preset configuration

UniverSheetsCorePreset

  • disableTextFormatAlert
    booleanDefault: false
    Disables the text format warning.
  • disableTextFormatMark
    booleanDefault: false
    Disables the text format marker.
TypeScript
import { UniverSheetsCorePreset } from '@univerjs/preset-sheets-core'import { createUniver } from '@univerjs/presets'const { univerAPI } = createUniver({  presets: [    UniverSheetsCorePreset({      disableTextFormatAlert: true,      disableTextFormatMark: true,    }),  ],})

Facade API

Importing

Plugin mode note

In plugin mode, the Facade package is imported separately. Preset mode includes the matching Facade package, so no additional import is required.

TypeScript
import '@univerjs/sheets-numfmt/facade'

Set number format

For the pattern syntax, see https://support.microsoft.com/en-us/office/number-format-codes-5026bbd6-04bc-48cd-bf33-80f18b4eae68

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getActiveSheet()// Set the number format of the A1 cell to '#,##0.00'.const fRange = fWorksheet.getRange('A1')fRange.setValue(1234.567).setNumberFormat('#,##0.00')fRange.getDisplayValue() // 1,234.57
TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getActiveSheet()// Set the number formats of the A1:B2 range.const fRange = fWorksheet.getRange('A1:B2')fRange.setValues([  [1234.567, 0.1234],  [45658, 0.9876],]).setNumberFormats([  ['#,##0.00', '0.00%'],  ['yyyy-MM-DD', ''],])fRange.getDisplayValues() // [['1,234.57', '12.34%'], ['2025-01-01', 0.9876]]

Get number format

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getActiveSheet()// Get the number format of the top-left cell of the A1:B2 range.const fRange = fWorksheet.getRange('A1:B2')fRange.getNumberFormat()
TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getActiveSheet()// Get the number formats of the A1:B2 range.const fRange = fWorksheet.getRange('A1:B2')fRange.getNumberFormats()

Set the locale for number formatting

FWorkbook.setNumfmtLocal(local) sets the locale used to format numbers.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getActiveSheet()const fRange = fWorksheet.getRange('A1')fRange.setValue(1234.567).setNumberFormat('#,##0.00')// Set the locale en for number formatting.fWorkbook.setNumfmtLocal('en')fRange.getDisplayValue() // 1,234.57// Set the locale de for number formatting.fWorkbook.setNumfmtLocal('de')fRange.getDisplayValue() // 1.234,57

Localized date presets

The date format panel derives its preset patterns and previews from Univer's current locale. Existing custom date patterns remain available. Changing the selected range refreshes the panel so that its controls match the current cells.

Footnotes

  1. Number formatting changes display, not the stored numeric value. For example, formatting 0.25 as 0% displays 25%; formulas still calculate with 0.25. ↩

How is this guide?

© 2026 DreamNum Co., Ltd.