Cell

Cell

A cell

Constructor

new Cell()

Source:

Methods

_evaluateFormula() → {*}

Source:

Evaluate the cell's formula. Note: This method does not save the formula to this cell.

Returns:

The result of the formula

Type
*

active() → {boolean}

Source:

Gets a value indicating whether the cell is the active cell in the sheet.

Returns:

True if active, false otherwise.

Type
boolean

active(active) → {Cell}

Source:

Make the cell the active cell in the sheet.

Parameters:
Name Type Description
active boolean

Must be set to true. Deactivating directly is not supported. To deactivate, you should activate a different cell instead.

Returns:

The cell.

Type
Cell

addHorizontalPageBreak() → {Cell}

Source:

Append horizontal page break after the cell.

Returns:

the cell.

Type
Cell

address(optsopt) → {string}

Source:

Get the address of the column.

Parameters:
Name Type Attributes Description
opts Object <optional>

Options

Properties
Name Type Attributes Description
includeSheetName boolean <optional>

Include the sheet name in the address.

rowAnchored boolean <optional>

Anchor the row.

columnAnchored boolean <optional>

Anchor the column.

anchored boolean <optional>

Anchor both the row and the column.

Returns:

The address

Type
string

clear() → {Cell}

Source:

Clears the contents from the cell.

Returns:

The cell.

Type
Cell

column() → {Column}

Source:

Gets the parent column of the cell.

Returns:

The parent column.

Type
Column

columnName() → {number}

Source:

Gets the column name of the cell.

Returns:

The column name.

Type
number

columnNumber() → {number}

Source:

Gets the column number of the cell (1-based).

Returns:

The column number.

Type
number

dataValidation() → {object|undefined}

Source:

Gets the data validation object attached to the cell.

Returns:

The data validation or undefined if not set.

Type
object | undefined

dataValidation(dataValidation) → {Cell}

Source:

Set or clear the data validation object of the cell.

Parameters:
Name Type Description
dataValidation object | undefined

Object or null to clear.

Returns:

The cell.

Type
Cell

dependencies() → {Array.<ReferenceLiteral>}

Source:
Returns:

The dependencies of the formula in this cell.

Type
Array.<ReferenceLiteral>

find(pattern, replacementopt) → {boolean}

Source:

Find the given pattern in the cell and optionally replace it.

Parameters:
Name Type Attributes Description
pattern string | RegExp

The pattern to look for. Providing a string will result in a case-insensitive substring search. Use a RegExp for more sophisticated searches.

replacement string | function <optional>

The text to replace or a String.replace callback function. If pattern is a string, all occurrences of the pattern in the cell will be replaced.

Returns:

A flag indicating if the pattern was found.

Type
boolean

formula() → {string}

Source:

Gets the formula in the cell. Note that if a formula was set as part of a range, the getter will return 'SHARED'. This is a limitation that may be addressed in a future release.

Returns:

The formula in the cell.

Type
string

formula(formula) → {Cell}

Source:

Sets the formula in the cell. The previous formula result will be removed.

Parameters:
Name Type Description
formula string | undefined | null

The formula to set.

Returns:

The cell.

Type
Cell

formula(formula, result) → {Cell}

Source:
Parameters:
Name Type Description
formula string

The formula to set.

result string | number | boolean | Date

The formula result.

Returns:

The cell

Type
Cell

getMasterSharedFormulaCell() → {Cell|undefined}

Source:

Get the master cell that stores the shared formula.

Returns:
  • The master cell.
Type
Cell | undefined

getStyle(name) → {*}

Source:

Get cell's style.

Parameters:
Name Type Description
name string

Style name

Returns:

Style

Type
*

getValue() → {string|boolean|number|Date|undefined|RichText}

Source:

Gets the value of the cell.

Returns:

The value of the cell.

Type
string | boolean | number | Date | undefined | RichText
Source:

Gets the hyperlink attached to the cell.

Returns:

The hyperlink or undefined if not set.

Type
string | undefined
Source:

Set or clear the hyperlink on the cell.

Parameters:
Name Type Description
hyperlink string | Cell | undefined | null

The hyperlink to set or undefined to clear.

Returns:

The cell.

Type
Cell
Source:

Set the internal/external hyperlink.

Parameters:
Name Type Description
hyperlink string | Cell | undefined

The hyperlink to set or undefined to clear.

internal boolean

Is internal hyperlink.

Returns:

The cell.

Type
Cell
Source:

Set the hyperlink options on the cell.

Parameters:
Name Type Description
opts Object | Cell

Options or Cell. If opts is a Cell then an internal hyperlink is added.

Properties
Name Type Attributes Description
hyperlink string | Cell <optional>

The hyperlink to set, can be a Cell or an internal/external string.

tooltip string <optional>

Additional text to help the user understand more about the hyperlink.

email string <optional>

Email address, ignored if opts.hyperlink is set.

emailSubject string <optional>

Email subject, ignored if opts.hyperlink is set.

Returns:

The cell.

Type
Cell

isMasterMergedCell(mergedopt) → {boolean}

Source:

Gets if this cell is the master merged cell. Node: If this cell is not part of a merged cell, return false.

Parameters:
Name Type Attributes Description
merged Object <optional>

Result from Cell.merged(), supply this can speed up performance.

Returns:
  • If the cell is master merged cell.
Type
boolean

isMasterShardFormula() → {boolean}

Source:
Returns:
  • If this cell is a master shared formula cell.
Type
boolean

isSharedFormula() → {boolean}

Source:
Returns:
  • If this cell contains shared formula.
Type
boolean

masterMergedCell(mergedopt) → {Cell|undefined}

Source:

Gets the master merged cell. Note: Return undefined if this cell is not part of the merged cell.

Parameters:
Name Type Attributes Description
merged Object <optional>

Result from Cell.merged(), supply this can speed up performance.

Returns:
  • The master merged cell.
Type
Cell | undefined

merged() → {boolean|Reference}

Source:

Gets a value indicating whether the cells in the range are merged.

Returns:

If it is merged, return a reference indicating where it merges, otherwise return false.

Type
boolean | Reference

rangeTo(cell) → {Range}

Source:

Create a range from this cell and another.

Parameters:
Name Type Description
cell Cell | string

The other cell or cell address to range to.

Returns:

The range.

Type
Range

recalculate() → {Array.<{}>}

Source:

Perform re-calculation, but not rebuild reference table

Returns:

A list of cells that updated.

Type
Array.<{}>

relativeCell(rowOffset, columnOffset) → {Cell}

Source:

Returns a cell with a relative position given the offsets provided.

Parameters:
Name Type Description
rowOffset number

The row offset (0 for the current row).

columnOffset number

The column offset (0 for the current column).

Returns:

The relative cell.

Type
Cell

row() → {Row}

Source:

Gets the parent row of the cell.

Returns:

The parent row.

Type
Row

rowNumber() → {number}

Source:

Gets the row number of the cell (1-based).

Returns:

The row number.

Type
number

setFormula(formula, calculateopt) → {Array.<{}>}

Source:

Sets the formula of this cell.

Parameters:
Name Type Attributes Default Description
formula string

The formula to set.

calculate boolean <optional>
true

Should the formula be calculated.

Returns:

The cells updated

Type
Array.<{}>

setStyle(name, value) → {Cell}

Source:

Set cell style

Parameters:
Name Type Description
name string

Style name

value *

Style

Returns:

The cell

Type
Cell

setValue(value, clearopt) → {Array.<{}>}

Source:

Sets the value of the cell.

Parameters:
Name Type Attributes Default Description
value RichText | string | boolean | number | null | undefined

The value to set.

clear boolean <optional>
true

If clear this cell.

Returns:

The cells updated

Type
Array.<{}>

sharedFormula() → {string}

Source:

Gets the translated shared formula. Based on the approach from https://github.com/dtjohnson/xlsx-populate/issues/129 but more efficient.

Returns:

Translated shared formula

Type
string

sheet() → {Sheet}

Source:

Gets the parent sheet.

Returns:

The parent sheet.

Type
Sheet

style(name) → {*}

Source:

Gets an individual style.

Parameters:
Name Type Description
name string

The name of the style.

Returns:

The style.

Type
*

style(names) → {object.<string, *>}

Source:

Gets multiple styles.

Parameters:
Name Type Description
names Array.<string>

The names of the style.

Returns:

Object whose keys are the style names and values are the styles.

Type
object.<string, *>

style(name, value) → {Cell}

Source:

Sets an individual style.

Parameters:
Name Type Description
name string

The name of the style.

value *

The value to set.

Returns:

The cell.

Type
Cell

style(name) → {Range}

Source:

Sets the styles in the range starting with the cell.

Parameters:
Name Type Description
name string

The name of the style.

Array.<Array.<*>>

2D array of values to set.

Returns:

The range that was set.

Type
Range

style(styles) → {Cell}

Source:

Sets multiple styles.

Parameters:
Name Type Description
styles object.<string, *>

Object whose keys are the style names and values are the styles to set.

Returns:

The cell.

Type
Cell

style(style) → {Cell}

Source:

Sets to a specific style

Parameters:
Name Type Description
style Style

Style object given from stylesheet.createStyle

Returns:

The cell.

Type
Cell

tap(callback) → {Cell}

Source:

Invoke a callback on the cell and return the cell. Useful for method chaining.

Parameters:
Name Type Description
callback Cell~tapCallback

The callback function.

Returns:

The cell.

Type
Cell

thru(callback) → {*}

Source:

Invoke a callback on the cell and return the value provided by the callback. Useful for method chaining.

Parameters:
Name Type Description
callback Cell~thruCallback

The callback function.

Returns:

The return value of the callback.

Type
*

value() → {string|boolean|number|Date|RichText|undefined}

Source:

Gets the value of the cell.

Returns:

The value of the cell.

Type
string | boolean | number | Date | RichText | undefined

value(value) → {Cell}

Source:

Sets the value of the cell.

Parameters:
Name Type Description
value string | boolean | number | null | undefined | RichText

The value to set.

Returns:

The cell.

Type
Cell

value() → {Range}

Source:

Sets the values in the range starting with the cell.

Parameters:
Type Description
Array.<Array.<(string|boolean|number|null|undefined)>>

2D array of values to set.

Returns:

The range that was set.

Type
Range

workbook() → {Workbook}

Source:

Gets the parent workbook.

Returns:

The parent workbook.

Type
Workbook

Type Definitions

tapCallback(cell) → {undefined}

Source:

Callback used by tap.

Parameters:
Name Type Description
cell Cell

The cell

Returns:
Type
undefined

thruCallback(cell) → {*}

Source:

Callback used by thru.

Parameters:
Name Type Description
cell Cell

The cell

Returns:

The value to return from thru.

Type
*