Spreadsheet
TypeScript/javascript spreadsheet.
Usage
Install
npm install js-spreadsheet
Examples
Using a Sheet
var Sheet = Sheet;var sheet = ;sheet;sheet;sheet;sheet;sheet;sheet; // returns: 1123.1
Using Formulas Directly
var Formulas = AllFormulas;Formulas; // returns: 28
For a full list of formulas, see DOCS.md
Nested Formulas
sheetsheet; // returns: 1
Date Conversion
sheetsheet; // returns: 4
Number Parsing
sheet;sheet; // returns: 144 sheet;sheet; // returns: 1000001 sheet;sheet; // returns: -10 sheet;sheet; // returns: 1.1 sheet;sheet; // returns: 1024
Ranges
In MS Excel, and Google Spreadsheets, literal ranges are denoted with opening and closing curly-brackets. E.g. "{1, 2, 3}". In this implementation however, literal ranges are denoted with opening and closing brackets. E.g. "[1, 2, 3]".
// OKsheet;// NOT OKsheet;
Docs
See DOCS.md for full list and documentation of all formulas available.
Contributing
When adding a formula, or fixing a bug please follow the commit message format:
[BUG_FEATURE_FILE_OR_COMPONENT] short description here of issue and fix
If you're adding a new formula, before you submit a pull request or push ensure that:
- The formula is tested inside the proper category file in
tests/Formulas
. - Make sure the formula is exported, and imported/exported in
AllFormulas.ts
. - The formula tests for reference errors, N/A errors, value errors for each input.
- That the formula is tested for parsing inside
SheetFormulaTest.ts
. - Run tests with
npm run test
. - Build with
npm run build
. - Build DOCS.md with
npm run docs
.
Why?
Near the end of 2016 I began to ask myself why I didn't know more about MS Excel and Google Spreadsheets. Why didn't I know more about the most popular programing language in the world? I began to reverse engineer Google Spreadsheets in particular, gaining a better understanding along the way.
I chose TypeScript because, coming from Java, it is really nice to be able to see type errors, and catch them. I also just enjoy getting specific with my return types, even if the specifications for a spreadsheet treat type flexibly.
For the formula documentation, I tried to be at least -- if not more -- thorough as Google Spreadsheets.
License
For this repository's code license, and related licenses, see LICENSES directory.
Acknowledgements
This is largely a re-write of Handsontable's https://github.com/handsontable/ruleJS, and https://github.com/sutoiku/formula.js/. The parser was derived from Handsontable's, and many of the formulas were created with FormulaJS's formulas as a reference point.