I've seen a number of questions where people ask for OpenPyxl to calculate formulas. For fun I took a crack at evaluating functions. To be clear, this is emulating Excel functions in Python, not using Excel to calculate them. It's pretty basic and only supports a handful of functions right now (ABS, SUM, AVERAGE, MIN, MAX, AND, OR, and IF). It's pretty easy to add new functions, but it would be a lot of work to fill out full emulation of all of the Excel functions! Some other caveats: It only handles basic cell and range references (no names, references to other sheets, etc.), and no circular reference checking. But it works pretty well (see the attached spreadsheet for some examples).
One other big caveat -- this isn't a safe way to do this. It would be pretty easy for someone to do code injection to do malicious things (e.g. write a formula like: = os.execv('...')
Thoughts?
Len