sheetjs_sheetjs/docbits/51_cell.md

1.7 KiB

Cell Object

Cell objects are plain JS objects with keys and values following the convention:

Key Description
v raw value (see Data Types section for more info)
w formatted text (if applicable)
t type: b Boolean, e Error, n Number, d Date, s Text, z Stub
f cell formula encoded as an A1-style string (if applicable)
F range of enclosing array if formula is array formula (if applicable)
r rich text encoding (if applicable)
h HTML rendering of the rich text (if applicable)
c comments associated with the cell
z number format string associated with the cell (if requested)
l cell hyperlink object (.Target holds link, .Tooltip is tooltip)
s the style/theme of the cell (if applicable)
p set to truthy value to remove the lock for a password protected cell

Built-in export utilities (such as the CSV exporter) will use the w text if it is available. To change a value, be sure to delete cell.w (or set it to undefined) before attempting to export. The utilities will regenerate the w text from the number format (cell.z) and the raw value if possible.

The actual array formula is stored in the f field of the first cell in the array range. Other cells in the range will omit the f field.

When protecting a sheet with ws["!protect"] use cell.p to unlock the cell