@yiminghe/excel-formula
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

excel formula engine

https://github.com/yiminghe/kison

usage

import { parser, FormulaEngine } from '@yiminghe/excel-formula';

console.log(parser.parse('sum(a1,a2)'));

console.log('*'.repeat(20));

// or
console.log(
  parser.parse('sum(a1;a2)', {
    lexerOptions: { env: 'de' },
  }),
);

console.log('*'.repeat(20));

const engine = new FormulaEngine();

engine.initWithValues([
  [{
    type: 'number',
    value: 1
  },
  {
    type: 'formula',
    formula: '=a1'
  }
  ]
]);

console.log(engine.getCellValue({
  row: 1,
  col: 2
}));

api

export declare class FormulaEngine {
    initWithValues(values: CellValue[][], options?: FormulaEngineOptions): ChangedCell[] | undefined;
    setCellValue(address: CellAddress, cell: CellValue): ChangedCell[];
    get width(): number;
    get height(): number;
    getCellValue(address: CellAddress): CellValue;
    insertRows(before: number, count?: number): ChangedCell[];
    deleteRows(at: number, count?: number): ChangedCell[];
    evaluateFormula(formula: string): All_Value_Type;
}

feature

  • function: sum(a1:a2,b1)
  • intersection: sum(a1:a2 b1)
  • union: sum((a1:a2,b1))
  • 3d reference: sum(shee1:sheet2!a1:a2)
  • structure reference: sum(t[[#total],[y]],t[x])
  • array formula and spilled reference: @sum(@a1:a2 a3#, {1;2}+{2,3})

Readme

Keywords

none

Package Sidebar

Install

npm i @yiminghe/excel-formula

Weekly Downloads

0

Version

0.1.3

License

MIT

Unpacked Size

304 kB

Total Files

54

Last publish

Collaborators

  • yiminghe