Class: ExpressionModifier

ExpressionModifier

Component adds an ability to parse and modify formula expressions. It is designed for translating cell
coordinates and cell ranges in any direction. By default, component translates only relative coordinates but this
behavior can be overwritten by passing custom modifier which controls translating process.

Members

cellsArray

Extracted cells and cells ranges.

customModifiernull function

Function which can modify default behaviour of how cells and cell ranges will be translated.

expressionString

Formula expression to modify.

Methods

setExpression(expression){ExpressionModifier}

Set formula expression to modify.

Parameters:
Name Type Description
expression String

Formula expression to process.

Returns: {ExpressionModifier}

toString(){String}

Translate object into string representation.

Returns: {String}

translate(delta, startFrom){ExpressionModifier}

Translate formula expression cells.

Parameters:
Name Type Description
delta Object

Distance to move in proper direction.

startFrom Object optional

Coordinates which translation will be applied from.

Returns: {ExpressionModifier}

useCustomModifier(customModifier)

Set function which can modify default behavior of how cells and cell ranges will be translated.
The passed function will be called with 4 arguments:

  • cell, A cell object with structure
        like this: {start: {row, column}, end: {row, column}, origLabel, type: 'cell|range', refError, toLabel: () => {}}
  • axis, Type of currently processing axis ('row' or 'column')
  • delta, Number as distance to translate. Can be positive or negative.
  • startFromIndex, Base index which translation will be applied from.

the function must return an array with 3 items, where:
[
deltaStart, Number as a delta to translate first part of coordinates.
deltaEnd, Number as a delta to translate second part of coordinates (if cell range is modified).
refError, Defines an error which refers to the situation when translated cell overcrossed the data boundary.
]

Parameters:
Name Type Description
customModifier function

Function with custom logic.