# Introduction

Welcome to HyperFormula v0.6.2 API!

The API reference documentation provides detailed information for methods, error types, event types, and all the configuration options available in HyperFormula.

Current build: 26/05/2021 09:34:04

# API reference index

The following sections explain shortly what can be found in the left sidebar navigation menu.

# HyperFormula

This section contains information about the class for creating HyperFormula instance. It enlists all available public methods alongside their descriptions, parameter types, and examples.

The snippet shows an example how to use buildFromArray which is one of three static methods for creating an instance of HyperFormula:

const sheetData = [
  ['0', '=SUM(1,2,3)', '52'],
  ['=SUM(A1:C1)', '', '=A1'],
  ['2', '=SUM(A1:C1)', '91'],
];

const hfInstance = HyperFormula.buildFromArray(sheetData, options);

# Configuration Options

This section contains information about options that allow you to configure the instance of HyperFormula.

An example set of options:

const options = {
  licenseKey: 'agpl-v3',
  precisionRounding: 10,
  nullDate: { year: 1900, month: 1, day: 1 },
  functionArgSeparator: '.'
};

# Event Types

In this section, you can find information about all events you can subscribe to.

For example, subscribing to sheetAdded event:

const hfInstance = HyperFormula.buildFromSheets({
  MySheet1: [ ['1'] ],
  MySheet2: [ ['10'] ],
});

const handler = ( ) => { console.log('baz') }

hfInstance.on('sheetAdded', handler);

const nameProvided = hfInstance.addSheet('MySheet3');

# Error Types

This page is a list of errors thrown by the HyperFormula instance that may be thrown depending on the method used.

An example of how you can handle an error: adding a sheet which name is already taken:

// variable used to carry the message for the user
let messageUsedInUI;

// attempt to add a sheet
try {
  hfInstance.addSheet('MySheet1');

// whoops! there is already a sheet named 'MySheet1'
} catch (e) {

  // notify the user that a sheet with an ID of 5 does not exist
  if (e instanceof SheetNameAlreadyTakenError) {
     messageUsedInUI = 'Sheet name already taken';
  }
  // a generic error message, just in case
  else {
     messageUsedInUI = 'Something went wrong';
  }
}