Cell Data Structure

Cell position

Univer Sheets stores cell data in the cellData field of an IWorksheetData object. That field holds all information about a cell, including its value, style, and type.

The code below shows the shape of cellData.

TypeScript
interface IWorksheetData {  cellData: {    // first row    0: {      // first column      0: { v: 'A1' }      // second column      1: { v: 'B1' }    }    // second row    1: {      // first column      0: { v: 'A2' }      // second column      1: { v: 'B2' }    }  }}

Cell data

A cell has the following properties.

PropertyDescription
vCell original value
sCell style id or style object
tCell type
pRich text, also a 📝 Univer Docs
fFormula
siFormula id
customCustom field

See ICellData for the type of each property.

Cell original value

cellData.v holds the original value of a cell, which is either a string or a number. In a cell that has a formula, v holds the result of that formula.

The example below stores a string in one cell and a number in the other.

TypeScript
interface IWorksheetData {  cellData: {    0: {      0: { v: 'A1' }      1: { v: 1 }    }  }}

Cell style

cellData.s holds either a style id or a style object.

When s is a string, it is a style id. Univer Sheets optimizes styles by reference, so a repeated style object is stored once, in the styles field of IWorkbookData. That field is a map: each key is a style id, and each value is a style object.

Avoid color values that carry transparency, such as rgba. When a cell with that kind of background enters the editing state, the content of the cell underneath shows through.

TypeScript
interface IWorkbookData {  styles: {    random_style_id_1: {      fs: 12      bg: {        rgb: '#ff0000'      }    }  }}

When a cell references that id, the style object is reused.

TypeScript
interface IWorksheetData {  cellData: {    0: {      0: {        v: 'A1'        s: 'random_style_id_1'      }      1: {        v: 'B1'        s: 'random_style_id_1'      }    }  }}

When s is an object, it is a complete style object (IStyleData).

The style fields are listed below.

PropertyDescription
ffFont
fsFont size
itItalic
blBold
ulUnderline
stStrikethrough
olOverline
bgBackground color
bdBorder
clFont color
vaSuperscript or subscript
trText rotation
htHorizontal alignment
vtVertical alignment
tbTruncate overflow
pdPadding
nNumber format

See IStyleData for the type of each field.

Font

ff is the font name, as a string.

TypeScript
interface IStyleData {  ff: 'Arial' // Font name is Arial}

Font size

fs is a number, in pt.

TypeScript
interface IStyleData {  fs: 12 // Font size is 12 pt}

Italic

it is a boolean number: 0 means not italic, and 1 means italic.

TypeScript
interface IStyleData {  it: 1 // Italic}

Bold

bl is a boolean number: 0 means not bold, and 1 means bold.

TypeScript
interface IStyleData {  bl: 1 // Bold}

Underline

ul is an object that describes the underline style.

TypeScript
interface IStyleData {  ul: {    s: 1 // Whether to show underline    c: 0 // Whether the color follows the font color. When `c` is 1 (TRUE), cl does not work. The default value is 1    cl: { // Underline color      rgb: '#ff0000'    }    t: 0 // Underline type  }}

Strikethrough

st is an object that describes the strikethrough style.

TypeScript
interface IStyleData {  st: {    s: 1 // Whether to show strikethrough    c: 0 // Whether the color follows the font color. When `c` is 1 (TRUE), cl does not work. The default value is 1    cl: { // Strikethrough color      rgb: '#ff0000'    }    t: 0 // Strikethrough type  }}

Overline

ol is an object that describes the overline style.

TypeScript
interface IStyleData {  ol: {    s: 1 // Whether to show overline    c: 0 // Whether the color follows the font color. When `c` is 1 (TRUE), cl does not work. The default value is 1    cl: { // Overline color      rgb: '#ff0000'    }    t: 0 // Overline type  }}

Background color

bg is an object that describes the background color.

TypeScript
interface IStyleData {  bg: {    rgb: '#ff0000' // Background color is red  }}

Border

bd is an object that describes the border style.

TypeScript
interface IStyleData {  bd: {    // Top border    t: {      s: 0 // Border style      cl: { // Border color        rgb: '#ff0000'      }    }    // Bottom border    b: {      s: 0 // Border style      cl: { // Border color        rgb: '#ff0000'      }    }    // Left border    l: {      s: 0 // Border style      cl: { // Border color        rgb: '#ff0000'      }    }    // Right border    r: {      s: 0 // Border style      cl: { // Border color        rgb: '#ff0000'      }    }  }}

Font color

cl is an object that describes the font color.

TypeScript
interface IStyleData {  cl: {    rgb: '#ff0000' // Font color is red  }}

Superscript or subscript

va is an enum number: 1 means normal, 2 means subscript, and 3 means superscript.

TypeScript
interface IStyleData {  va: 2 // Subscript}

Text rotation

tr is an object that describes text rotation.

TypeScript
interface IStyleData {  tr: {    a: 0 // Text rotation angle    v: 0 // Whether it is vertical. 1 means vertical, 0 means horizontal. The default value is 0. When v is 1, a is invalid  }}

Horizontal alignment

ht is an enum number: 1 means left alignment, 2 means center, and 3 means right alignment.

TypeScript
interface IStyleData {  ht: 1 // Left alignment}

Vertical alignment

vt is an enum number: 1 means top alignment, 2 means center, and 3 means bottom alignment.

TypeScript
interface IStyleData {  vt: 1 // Top alignment}

Truncate overflow

tb is an enum number: 1 means overflow, 2 means truncate, and 3 means wrap.

TypeScript
interface IStyleData {  tb: 1 // Overflow}

Padding

pd is an object that describes padding.

TypeScript
interface IStyleData {  pd: {    t: 0 // Top padding    b: 0 // Bottom paddingAdd commentMore actions    l: 0 // Left padding    r: 0 // Right padding  }}

Number format

n is an object. Its pattern field holds the number format as a string. Microsoft documents the format codes here.

If n is null, or if pattern is null, the cell uses the general format.

TypeScript
import type { DEFAULT_TEXT_FORMAT_EXCEL } from '@univerjs/core'interface IStyleData {  n: {    pattern: DEFAULT_TEXT_FORMAT_EXCEL // text format  }}

To keep a number that starts with 0, or one that could be converted to a date format, from being converted automatically, see number formatting.

Cell type

cellData.t is a CellValueType enum that sets the type of the cell. 1 means string, 2 means number, 3 means boolean, and 4 means force text. When the field is not set, Univer recognizes the type automatically.

A boolean cell stores cellData.v as 0 or 1: 0 means false, and 1 means true.

TypeScript
interface IWorksheetData {  cellData: {    0: {      0: {        v: 'A1'        t: 1 // String      }      1: {        v: 1        t: 2 // Number      }      2: {        v: 1 // TRUE        t: 3 // Boolean      }      3: {        v: '012.0'        t: 4 // Force text      }    }  }}

The force text alert and mark are controlled by disableForceStringAlert and disableForceStringMark. You can configure them in:

Rich text

cellData.p is an object that holds rich text, and that object is itself a Univer Doc. See IDocumentData for the full structure.

When a cell has both p and v set, only the contents of p are displayed.

cellData.p.body.dataStream is the rich text content.

Formula

cellData.f is a formula, stored as a string.

TypeScript
interface IWorksheetData {  cellData: {    0: {      0: {        f: '=SUM(A1:B1)' // function SUM      }    }  }}

Formula ID

cellData.si is a string that holds a formula id. Univer Sheets optimizes formulas by reference: once a cell associates its formula with an si, other cells can refer to that same formula through the si. The cell that carries the si must be at the lower right corner of the reference cell; otherwise, exporting to XLSX raises an error.

Call the Facade API range.getFormulas() to get the actual formula. It takes the formula f that si points to and then computes the real formula from the offset between the current cell position and the reference position.

TypeScript
interface IWorksheetData {  cellData: {    0: {      0: {        f: '=SUM(A1:B1)' // Sum formula        si: 'random_formula_id_1' // ID of the current formula      }      1: {        si: 'random_formula_id_1' // Take the formula corresponding to this ID during calculation      }    }  }}

Custom field

cellData.custom is an object that serves as a custom field. It accepts any data that is valid JSON, so it can store additional information of your own.

Updating custom data overwrites the existing custom data rather than merging into it. To keep the existing custom data, read the custom data first, merge it into the new data, and then update.

The custom field applies only to a few special scenarios. Any user operation can overwrite or delete the data stored in this field, so use it with caution.

TypeScript
interface IWorksheetData {  cellData: {    0: {      0: {        custom: {          key: 'value'        }      }    }  }}

How is this guide?

© 2026 DreamNum Co., Ltd.