4 ms·
The Calculoid people have publicly disclosed (https://github.com/calculoidapp/calculoidapp.github.io/wiki/Formula-Field https://github.com/calculoidapp/calculoi
by davidpolberger 7y ago
The Calculoid people have publicly disclosed (https://github.com/calculoidapp/calculoidapp.github.io/wiki/Formula-Field https://github.com/calculoidapp/calculoidapp.github.io/wiki/...) they they're using this library for evaluating formulas:
https://silentmatt.com/javascript-expression-evaluator/ https://silentmatt.com/javascript-expression-evaluator/
Through that library, they support a limited number of functions, which map more closely to the built-in Math object of JavaScript than to Excel.
We (Calcapp) have a custom-written compiler, which our server uses as a library for checking formulas and producing JavaScript code. In 2016, we changed our formula syntax to be largely compatible with what Excel and other spreadsheets use (https://www.calcapp.net/blog/2016/06/02/formula-syntax.html https://www.calcapp.net/blog/2016/06/02/formula-syntax.html).
We support 281 formula functions, most of them compatible with what spreadsheets offer (https://www.calcapp.net/learn/functions.html https://www.calcapp.net/learn/functions.html). We have around a thousand unit tests verifying that we get the same results as Excel.
Thanks to our extensive function library, importing spreadsheets is often straight-forward (https://www.calcapp.net/blog/2017/06/14/convert.html https://www.calcapp.net/blog/2017/06/14/convert.html). (We don't do a good job of supporting table look-ups, though, and we will soon turn our focus towards solving that problem.)
Our function library is released under the MIT license and is available on GitHub:
https://github.com/davidpolberger/formulajs https://github.com/davidpolberger/formulajs
It is a fork of an existing library (formulajs) and includes a fair number of bug fixes and improvements.
At runtime, apps make use of a dependency graph generated by the compiler to ensure that calculations aren't run needlessly. As far as I'm aware, this is the same technique used by all spreadsheets.
It would be straightforward to analyze a workbook and build a dependency graph to determine inputs and outputs. From there, an app could be generated. The only issue is inferring the user interface -- labels often appear to the left of the input and output cells, and while this could be used as a heuristic, it wouldn't be perfect. I've toyed with the idea of using machine learning to do a better job of inferring a user interface.