Convert Figma logo to code with AI

handsontable logohyperformula

HyperFormula is an open-source headless spreadsheet for business web apps. It comes with over 400 formulas, CRUD operations, undo-redo, clipboard support, and sorting.

2,350
128
2,350
145

Top Related Projects

35,733

📗 SheetJS Spreadsheet Data Toolkit -- New home https://git.sheetjs.com/SheetJS/sheetjs

14,513

Excel Workbook Manager

JavaScript implementation of most Microsoft Excel formula functions

Quick Overview

HyperFormula is a high-performance, in-memory spreadsheet engine that can be embedded into web applications. It provides a comprehensive set of features for working with tabular data, including support for formulas, cell references, and various data types.

Pros

  • High Performance: HyperFormula is designed to be highly efficient, allowing for fast calculations and updates even with large datasets.
  • Comprehensive Feature Set: The library supports a wide range of spreadsheet functionality, including formulas, cell references, and various data types.
  • Flexible Integration: HyperFormula can be easily integrated into web applications, providing a seamless spreadsheet experience for users.
  • Open-Source: The project is open-source, allowing for community contributions and customizations.

Cons

  • Steep Learning Curve: Integrating HyperFormula into a project may require a significant amount of time and effort, especially for developers unfamiliar with spreadsheet engines.
  • Limited Documentation: The project's documentation could be more comprehensive, making it challenging for new users to get started.
  • Dependency on External Libraries: HyperFormula relies on several external libraries, which may introduce additional complexity and potential compatibility issues.
  • Limited Community Support: Compared to more widely-used libraries, the HyperFormula community is relatively small, which could impact the availability of support and resources.

Code Examples

Here are a few examples of how to use HyperFormula in your code:

  1. Creating a new HyperFormula instance:
import { HyperFormula } from 'hyperformula';

const hf = HyperFormula.buildEmpty({
  licenseKey: 'your-license-key-here',
  columnCount: 10,
  rowCount: 100,
});
  1. Evaluating a formula:
const result = hf.evaluate('SUM(A1:A10)');
console.log(result); // Outputs the sum of the values in cells A1 through A10
  1. Updating cell values:
hf.setCellValue('A1', 10);
hf.setCellValue('A2', 20);
hf.recalculate();
  1. Retrieving data as a 2D array:
const data = hf.getData();
console.log(data); // Outputs the current state of the spreadsheet as a 2D array

Getting Started

To get started with HyperFormula, follow these steps:

  1. Install the library using npm or yarn:
npm install hyperformula
  1. Import the HyperFormula class and create a new instance:
import { HyperFormula } from 'hyperformula';

const hf = HyperFormula.buildEmpty({
  licenseKey: 'your-license-key-here',
  columnCount: 10,
  rowCount: 100,
});
  1. Use the various methods provided by the HyperFormula instance to interact with the spreadsheet data, such as setting cell values, evaluating formulas, and retrieving data.

  2. Refer to the HyperFormula documentation for more detailed information on the available features and usage examples.

Competitor Comparisons

35,733

📗 SheetJS Spreadsheet Data Toolkit -- New home https://git.sheetjs.com/SheetJS/sheetjs

Pros of SheetJS

  • Broader file format support, including Excel, CSV, and various spreadsheet formats
  • More mature project with a larger community and extensive documentation
  • Lightweight and efficient, suitable for both browser and Node.js environments

Cons of SheetJS

  • Less focus on formula calculation capabilities
  • May require additional libraries for advanced spreadsheet functionalities
  • Commercial use requires a paid license

Code Comparison

SheetJS

const XLSX = require('xlsx');
const workbook = XLSX.readFile('example.xlsx');
const sheet = workbook.Sheets[workbook.SheetNames[0]];
const data = XLSX.utils.sheet_to_json(sheet);
console.log(data);

HyperFormula

const HyperFormula = require('hyperformula');
const hf = HyperFormula.buildEmpty();
const sheetName = hf.addSheet('Sheet1');
hf.setCellContents({ sheet: sheetName, row: 0, col: 0 }, '=SUM(1,2,3)');
console.log(hf.getCellValue({ sheet: sheetName, row: 0, col: 0 }));

SheetJS focuses on file parsing and generation, while HyperFormula specializes in formula calculation and spreadsheet logic. SheetJS is more versatile for working with various file formats, whereas HyperFormula excels in complex calculations and maintaining spreadsheet state.

14,513

Excel Workbook Manager

Pros of ExcelJS

  • More comprehensive Excel file manipulation, including reading, writing, and editing
  • Supports a wider range of Excel features, such as styles, formulas, and charts
  • Larger community and more frequent updates

Cons of ExcelJS

  • Heavier and potentially slower for large datasets
  • More complex API, which may require a steeper learning curve
  • Primarily focused on Excel file handling, not optimized for in-memory calculations

Code Comparison

ExcelJS:

const workbook = new ExcelJS.Workbook();
const worksheet = workbook.addWorksheet('Sheet1');
worksheet.getCell('A1').value = 'Hello, World!';
await workbook.xlsx.writeFile('example.xlsx');

HyperFormula:

const hf = HyperFormula.buildEmpty();
const sheetId = hf.addSheet('Sheet1');
hf.setCellContents({ sheet: sheetId, row: 0, col: 0 }, 'Hello, World!');
const value = hf.getCellValue({ sheet: sheetId, row: 0, col: 0 });

Summary

ExcelJS is better suited for comprehensive Excel file manipulation, offering a wide range of features and strong community support. HyperFormula, on the other hand, excels in high-performance, in-memory calculations and formula processing. Choose ExcelJS for full-featured Excel file handling, and HyperFormula for efficient spreadsheet-like calculations in web applications.

JavaScript implementation of most Microsoft Excel formula functions

Pros of formula.js

  • Lightweight and focused on Excel-like formula calculations
  • Extensive function coverage, including financial and statistical functions
  • Easy to integrate into existing JavaScript projects

Cons of formula.js

  • Less actively maintained, with fewer recent updates
  • Limited to formula calculations, lacking advanced spreadsheet features
  • Smaller community and ecosystem compared to HyperFormula

Code Comparison

formula.js:

var result = formulajs.SUM(1, 2, 3, 4);
console.log(result); // Output: 10

HyperFormula:

const hf = HyperFormula.buildEmpty();
const sheetId = hf.addSheet('Sheet1');
hf.setCellContents({ sheet: sheetId, row: 0, col: 0 }, '=SUM(1,2,3,4)');
console.log(hf.getCellValue({ sheet: sheetId, row: 0, col: 0 })); // Output: 10

formula.js provides a more straightforward API for direct formula calculations, while HyperFormula offers a more comprehensive spreadsheet-like environment with cell references and sheet management. HyperFormula's approach is better suited for complex spreadsheet applications, while formula.js excels in simpler formula-based calculations within existing JavaScript projects.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README


HyperFormula - A headless spreadsheet, a parser and evaluator of Excel formulas

An open-source headless spreadsheet for business web apps

npm total downloads npm monthly downloads GitHub contributors Known Vulnerabilities
FOSSA Status GitHub Workflow Status codecov


HyperFormula is a headless spreadsheet built in TypeScript, serving as both a parser and evaluator of spreadsheet formulas. It can be integrated into your browser or utilized as a service with Node.js as your back-end technology.

What HyperFormula can be used for?

HyperFormula doesn't assume any existing user interface, making it a general-purpose library that can be used in various business applications. Here are some examples:

  • Custom spreadsheet-like app
  • Business logic builder
  • Forms and form builder
  • Educational app
  • Online calculator

Features

Documentation

Integrations

Installation and usage

Install the library from npm like so:

npm install hyperformula

Once installed, you can use it to develop applications tailored to your specific business needs. Here, we've used it to craft a form that calculates mortgage payments using the PMT formula.

import { HyperFormula } from 'hyperformula';

// Create a HyperFormula instance
const hf = HyperFormula.buildEmpty({ licenseKey: 'gpl-v3' });

// Add an empty sheet
const sheetName = hf.addSheet('Mortgage Calculator');
const sheetId = hf.getSheetId(sheetName);

// Enter the mortgage parameters
hf.addNamedExpression('AnnualInterestRate', '8%');
hf.addNamedExpression('NumberOfMonths', 360);
hf.addNamedExpression('LoanAmount', 800000);

// Use the PMT function to calculate the monthly payment
hf.setCellContents({ sheet: sheetId, row: 0, col: 0 }, [['Monthly Payment', '=PMT(AnnualInterestRate/12, NumberOfMonths, -LoanAmount)']]);

// Display the result
console.log(`${hf.getCellValue({ sheet: sheetId, row: 0, col: 0 })}: ${hf.getCellValue({ sheet: sheetId, row: 0, col: 1 })}`);

Run this code in StackBlitz

Contributing

Contributions are welcome, but before you make them, please read the Contributing Guide and accept the Contributor License Agreement.

License

HyperFormula is available under two different licenses: GPLv3 and proprietary. The proprietary license can be purchased by contacting our team at Handsontable.

Copyright (c) Handsoncode

NPM DownloadsLast 30 Days