Home Reference Source
import {Cell} from 'better-xlsx/src/cell.js'
public class | source

Cell

Cell intended to provide user access to the contents of Cell within an xlsx.Row.

const cell = row.addCell();
cell.value = 'I am a cell!';
cell.hMerge = 2;
cell.vMerge = 1;
cell.style.fill.patternType = 'solid';
cell.style.fill.fgColor = '00FF0000';
cell.style.fill.bgColor = 'FF000000';
cell.style.align.h = 'center';
cell.style.align.v = 'center';

Set the cell value

const cell = row.addCell();
// Date type
cell.setDate(new Date());
// Number type
cell.setNumber(123456);
cell.numFmt = '$#,##0.00';

Constructor Summary

Private Constructor
private

Create a cell and add it to a row.

Member Summary

Public Members
public

Horizontal merge with other cells.

public

Hide the cell.

public

Number format @see NumFmt

public get

style: Style: *

Get the cell style.

public set

style(s: Style)

Set the style of the cell.

public

Vertical merge with other cells.

public get

value: *

Get the cell value.

public set

Set the cell value.

Method Summary

Public Methods
public

Set cell value with Boolean type.

public

Set cell value with Date type.

public

Set cell value with DateTime type.

public

Set cell formula.

public

Set cell value with Number type.

public

Set cell value with String type.

Private Constructors

private constructor() source

Create a cell and add it to a row.

Params:

NameTypeAttributeDescription
options.row Object

Row of add to

Public Members

public hMerge: Number source

Horizontal merge with other cells.

public hidden: Boolean source

Hide the cell.

public numFmt: String source

Number format @see NumFmt

public get style: Style: * source

Get the cell style.

Return:

Style

public set style(s: Style) source

Set the style of the cell.

public vMerge: Number source

Vertical merge with other cells.

public get value: * source

Get the cell value.

public set value(v: String | Date | Number | Boolean) source

Set the cell value.

Public Methods

public setBool(v: Boolean) source

Set cell value with Boolean type.

Params:

NameTypeAttributeDescription
v Boolean

public setDate(v: Date) source

Set cell value with Date type.

Params:

NameTypeAttributeDescription
v Date

public setDateTime(v: Date) source

Set cell value with DateTime type.

Params:

NameTypeAttributeDescription
v Date

public setFormula(f: String) source

Set cell formula.

Params:

NameTypeAttributeDescription
f String

Formula like B2*C2-D2.

public setNumber(v: Number) source

Set cell value with Number type.

Params:

NameTypeAttributeDescription
v Number

public setString(v: String) source

Set cell value with String type.

Params:

NameTypeAttributeDescription
v String