Listeners
evaluationResumed
Section titled “evaluationResumed”• evaluationResumed: function
Defined in src/Emitter.ts:316
Occurs when evaluation is resumed.
param the values and location of applied changes
example
const hfInstance = HyperFormula.buildFromSheets({ MySheet1: [ ['1'] ], MySheet2: [ ['10'] ]});
// define a function to be called when the event occursconst handler = (changes) => { console.log('baz') }
// subscribe to the 'evaluationResumed' event, pass the handlerhfInstance.on('evaluationResumed', handler);
// first, suspend evaluationhfInstance.suspendEvaluation();
// now, resume evaluation// the console prints 'baz' each time evaluation is resumedhfInstance.resumeEvaluation();
// unsubscribe from the 'evaluationResumed' eventhfInstance.off('evaluationResumed', handler);
// suspend evaluation againhfInstance.suspendEvaluation();
// resume evaluation again// this time, the console doesn't print anythinghfInstance.resumeEvaluation();;Type declaration:
Section titled “Type declaration:”▸ (changes: ExportedChange[]): any
Parameters:
| Name | Type |
|---|---|
changes | ExportedChange[] |
evaluationSuspended
Section titled “evaluationSuspended”• evaluationSuspended: function
Defined in src/Emitter.ts:274
Occurs when evaluation is suspended.
example
const hfInstance = HyperFormula.buildFromSheets({ MySheet1: [ ['1'] ], MySheet2: [ ['10'] ]});
// define a function to be called when the event occursconst handler = ( ) => { console.log('baz') }
// subscribe to the 'evaluationSuspended' event, pass the handlerhfInstance.on('evaluationSuspended', handler);
// suspend evaluation// the console prints 'baz' each time evaluation is suspendedhfInstance.suspendEvaluation();
// resume evaluationhfInstance.resumeEvaluation();
// unsubscribe from the 'evaluationSuspended' eventhfInstance.off('evaluationSuspended', handler);
// suspend evaluation again// this time, the console doesn't print anythinghfInstance.suspendEvaluation();;Type declaration:
Section titled “Type declaration:”▸ (): any
Named Expression
Section titled “Named Expression”namedExpressionAdded
Section titled “namedExpressionAdded”• namedExpressionAdded: function
Defined in src/Emitter.ts:162
Occurs when a named expression with specified values and location is added.
param the name of added expression
param the values and location of applied changes
example
const hfInstance = HyperFormula.buildFromArray([ ['42'],]);
// define a function to be called when the event occursconst handler = (namedExpressionName, changes) => { console.log('baz') }
// subscribe to the 'namedExpressionAdded' event, pass the handlerhfInstance.on('namedExpressionAdded', handler);
// add a named expression// the console prints 'baz' each time a named expression is addedconst changes = hfInstance.addNamedExpression('prettyName', '=Sheet1!$A$1+100', 0);
// unsubscribe from the 'namedExpressionAdded' eventhfInstance.off('namedExpressionAdded', handler);
// add another named expression// this time, the console doesn't print anythingconst changes = hfInstance.addNamedExpression('uglyName', '=Sheet1!$A$1+100', 0);Type declaration:
Section titled “Type declaration:”▸ (namedExpressionName: string, changes: ExportedChange[]): any
Parameters:
| Name | Type |
|---|---|
namedExpressionName | string |
changes | ExportedChange[] |
namedExpressionRemoved
Section titled “namedExpressionRemoved”• namedExpressionRemoved: function
Defined in src/Emitter.ts:202
Occurs when a named expression with specified values is removed and from an indicated location.
param the name of removed expression
param the values and location of applied changes
example
const hfInstance = HyperFormula.buildFromArray([ ['42'],]);
// define a function to be called when the event occursconst handler = (namedExpressionName, changes) => { console.log('baz') }
// subscribe to the 'namedExpressionRemoved' event, pass the handlerhfInstance.on('namedExpressionRemoved', handler);
// add some named expressionshfInstance.addNamedExpression('prettyName', '=Sheet1!$A$1+100', 0);hfInstance.addNamedExpression('uglyName', '=Sheet1!$A$1+100', 0);
// remove a named expression// the console prints 'baz' each time a named expression is removedconst changes = hfInstance.removeNamedExpression('prettyName', 0);
// unsubscribe from the 'namedExpressionRemoved' eventhfInstance.off('namedExpressionRemoved', handler);
// remove another named expression// this time, the console doesn't print anythingconst changes = hfInstance.removeNamedExpression('uglyName', 0);Type declaration:
Section titled “Type declaration:”▸ (namedExpressionName: string, changes: ExportedChange[]): any
Parameters:
| Name | Type |
|---|---|
namedExpressionName | string |
changes | ExportedChange[] |
sheetAdded
Section titled “sheetAdded”• sheetAdded: function
Defined in src/Emitter.ts:52
Occurs when a sheet is added anywhere inside the workbook.
param the name of added sheet
example
const hfInstance = HyperFormula.buildEmpty();
// define a function to be called when the event occursconst handler = (addedSheetDisplayName) => { console.log('baz') }
// subscribe to the 'sheetAdded' event, pass the handlerhfInstance.on('sheetAdded', handler);
// add a sheet to trigger the 'sheetAdded' event,// the console prints 'baz' each time a sheet is addedhfInstance.addSheet('FooBar');
// unsubscribe from the 'sheetAdded' eventhfInstance.off('sheetAdded', handler);
// add a sheet// this time, the console doesn't print anythinghfInstance.addSheet('FooBaz');Type declaration:
Section titled “Type declaration:”▸ (addedSheetDisplayName: string): any
Parameters:
| Name | Type |
|---|---|
addedSheetDisplayName | string |
sheetRemoved
Section titled “sheetRemoved”• sheetRemoved: function
Defined in src/Emitter.ts:89
Occurs when a sheet is removed from anywhere inside the workbook.
param the name of removed sheet
param the values and location of applied changes
example
const hfInstance = HyperFormula.buildFromSheets({ MySheet1: [ ['=SUM(MySheet2!A1:A2)'] ], MySheet2: [ ['10'] ],});
// define a function to be called when the event occursconst handler = (removedSheetDisplayName, changes) => { console.log('baz') }
// subscribe to the 'sheetRemoved' event, pass the handlerhfInstance.on('sheetRemoved', handler);
// remove a sheet to trigger the 'sheetRemoved' event,// the console prints 'baz' each time a sheet is removedhfInstance.removeSheet(0);
// unsubscribe from the 'sheetRemoved' eventhfInstance.off('sheetRemoved', handler);
// remove a sheet// this time, the console doesn't print anythinghfInstance.removeSheet(1);Type declaration:
Section titled “Type declaration:”▸ (removedSheetDisplayName: string, changes: ExportedChange[]): any
Parameters:
| Name | Type |
|---|---|
removedSheetDisplayName | string |
changes | ExportedChange[] |
sheetRenamed
Section titled “sheetRenamed”• sheetRenamed: function
Defined in src/Emitter.ts:126
Occurs when a sheet is renamed anywhere inside the workbook.
param the old name of a sheet before renaming
param the new name of the sheet after renaming
example
const hfInstance = HyperFormula.buildFromSheets({ MySheet1: [ ['=SUM(MySheet2!A1:A2)'] ], MySheet2: [ ['10'] ],});
// define a function to be called when the event occursconst handler = (oldName, newName) => { console.log(`Sheet ${oldName} was renamed to ${newName}`) }
// subscribe to the 'sheetRenamed' event, pass the handlerhfInstance.on('sheetRenamed', handler);
// rename a sheet to trigger the 'sheetRenamed' event,// the console prints `Sheet ${oldName} was renamed to ${newName}` each time a sheet is renamedhfInstance.renameSheet(0, 'MySheet0');
// unsubscribe from the 'sheetRenamed' eventhfInstance.off('sheetRenamed', handler);
// rename a sheet// this time, the console doesn't print anythinghfInstance.renameSheet(1, 'MySheet1');Type declaration:
Section titled “Type declaration:”▸ (oldDisplayName: string, newDisplayName: string): any
Parameters:
| Name | Type |
|---|---|
oldDisplayName | string |
newDisplayName | string |
Values
Section titled “Values”valuesUpdated
Section titled “valuesUpdated”• valuesUpdated: function
Defined in src/Emitter.ts:237
Occurs when values in a specified location are changed and cause recalculation.
param the values and location of applied changes
example
const hfInstance = HyperFormula.buildFromArray([ ['1', '2', '=A1'],]);
// define a function to be called when the event occursconst handler = (changes) => { console.log('baz') }
// subscribe to the 'valuesUpdated' event, pass the handlerhfInstance.on('valuesUpdated', handler);
// trigger recalculation, for example, with the 'setCellContents' method// the console prints 'baz' each time a value change triggers recalculationconst changes = hfInstance.setCellContents({ col: 3, row: 0, sheet: 0 }, [['=B1']]);
// unsubscribe from the 'valuesUpdated' eventhfInstance.off('valuesUpdated', handler);
// trigger another recalculation// this time, the console doesn't print anythingconst changes = hfInstance.setCellContents({ col: 3, row: 0, sheet: 0 }, [['=A1']]);Type declaration:
Section titled “Type declaration:”▸ (changes: ExportedChange[]): any
Parameters:
| Name | Type |
|---|---|
changes | ExportedChange[] |