1. What is formulas?

formulas implements an interpreter for Excel formulas, which parses and compile Excel formulas expressions.

Moreover, it compiles Excel workbooks to python and executes without using the Excel COM server. Hence, Excel is not needed.

2. Installation

To install it use (with root privileges):

$ pip install formulas

Or download the last git version and use (with root privileges):

$ python setup.py install

2.1. Install extras

Some additional functionality is enabled installing the following extras:

  • excel: enables to compile Excel workbooks to python and execute using: ExcelModel.
  • plot: enables to plot the formula ast and the Excel model.

To install formulas and all extras, do:

$ pip install formulas[all]

3. Basic Examples

The following sections will show how to:

  • parse a Excel formulas;
  • load, compile, and execute a Excel workbook;
  • extract a sub-model from a Excel workbook;
  • add a custom function.

3.1. Parsing formula

An example how to parse and execute an Excel formula is the following:

>>> import formulas
>>> func = formulas.Parser().ast('=(1 + 1) + B3 / A2')[1].compile()

To visualize formula model and get the input order you can do the following:

>>> list(func.inputs)
['A2', 'B3']
>>> func.plot(view=False)  # Set view=True to plot in the default browser.
SiteMap([(=((1 + 1) + (B3 / A2)), SiteMap())])

digraph dmap { graph [ratio=1] node [style=filled] label = <dmap> splines = ortho style = filled 18 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">((1 + 1) + (B3 / A2))</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-445ca173805a260dda86b21ea2618361bcf11e6b/bypass.html">bypass</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="((1 + 1) + (B3 / A2))"] 19 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">(1 + 1)</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">OperatorArray(2.0, dtype=object)</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="(1 + 1)"] 20 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">(B3 / A2)</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="(B3 / A2)"] 21 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-445ca173805a260dda86b21ea2618361bcf11e6b/lambda.html">+&lt;0&gt;</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="+<0>"] 22 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-445ca173805a260dda86b21ea2618361bcf11e6b/lambda-0.html">/</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="/"] 23 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">A2</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=A2] 24 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">B3</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=B3] 25 [label=end fillcolor=blue shape=egg] 26 [label=start fillcolor=red shape=egg] 20 -> 21 22 -> 20 24 -> 22 23 -> 22 26 -> 24 [xlabel=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">start --&gt; B3</TD></TR><TR><TD align="RIGHT" border="1">inp_id</TD><TD align="LEFT" border="1">1</TD></TR></TABLE>>] 19 -> 21 26 -> 23 [xlabel=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">start --&gt; A2</TD></TR><TR><TD align="RIGHT" border="1">inp_id</TD><TD align="LEFT" border="1">0</TD></TR></TABLE>>] 18 -> 25 [xlabel=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">((1 + 1) + (B3 / A2)) --&gt; end</TD></TR><TR><TD align="RIGHT" border="1">out_id</TD><TD align="LEFT" border="1">0</TD></TR></TABLE>>] 21 -> 18 }

Finally to execute the formula and plot the workflow:

>>> func(1, 5)
OperatorArray(7.0, dtype=object)
>>> func.plot(workflow=True, view=False)  # Set view=True to plot in the default browser.
SiteMap([(=((1 + 1) + (B3 / A2)), SiteMap())])

digraph workflow { graph [ratio=1] node [style=filled] label = <workflow> splines = ortho style = filled 71 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-5547f76397c8b36502d8f70d143512ae6983df24/((1__1)__(B3__A2))-output.html">((1 + 1) + (B3 / A2))</TD></TR><TR><TD align="RIGHT" border="1">input_filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-5547f76397c8b36502d8f70d143512ae6983df24/((1__1)__(B3__A2))-input_filter_0.html">((1 + 1) + (B3 / A2))-input_filter 0</TD></TR><TR><TD align="RIGHT" border="1">output_filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-5547f76397c8b36502d8f70d143512ae6983df24/((1__1)__(B3__A2))-output_filter_0.html">((1 + 1) + (B3 / A2))-output_filter 0</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">4.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="((1 + 1) + (B3 / A2))"] 72 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-5547f76397c8b36502d8f70d143512ae6983df24/(1__1)-output.html">(1 + 1)</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">OperatorArray(2.0, dtype=object)</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">0.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="(1 + 1)"] 73 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-5547f76397c8b36502d8f70d143512ae6983df24/(B3__A2)-output.html">(B3 / A2)</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">2.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="(B3 / A2)"] 74 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-5547f76397c8b36502d8f70d143512ae6983df24/lambda.html">+&lt;0&gt;</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">3.0</TD></TR><TR><TD align="RIGHT" border="1">started</TD><TD align="LEFT" border="1">2018-10-19T09:25:12.783950</TD></TR><TR><TD align="RIGHT" border="1">duration</TD><TD align="LEFT" border="1">0:00:00.000729</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="+<0>"] 75 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-5547f76397c8b36502d8f70d143512ae6983df24/lambda-0.html">/</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">1.0</TD></TR><TR><TD align="RIGHT" border="1">started</TD><TD align="LEFT" border="1">2018-10-19T09:25:12.783725</TD></TR><TR><TD align="RIGHT" border="1">duration</TD><TD align="LEFT" border="1">0:00:00.000121</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="/"] 76 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-5547f76397c8b36502d8f70d143512ae6983df24/A2-output.html">A2</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">0.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=A2] 77 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-5547f76397c8b36502d8f70d143512ae6983df24/B3-output.html">B3</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">0.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=B3] 78 [label=start fillcolor=red shape=egg] 73 -> 74 78 -> 72 75 -> 73 77 -> 75 76 -> 75 78 -> 76 72 -> 74 78 -> 77 74 -> 71 }

3.2. Excel workbook

An example how to load, calculate, and write an Excel workbook is the following:

>>> import formulas
>>> fpath = 'file.xlsx'  
>>> xl_model = formulas.ExcelModel().loads(fpath).finish()
>>> xl_model.calculate()
Solution(...)
>>> xl_model.write()
{'EXCEL.XLSX': {Book: <openpyxl.workbook.workbook.Workbook ...>}}

Tip

If you have or could have circular references, add circular=True to finish method.

To plot the dependency graph that depict relationships between Excel cells:

>>> dsp = xl_model.dsp
>>> dsp.plot(view=False)  # Set view=True to plot in the default browser.
SiteMap([(Dispatcher ..., SiteMap())])

digraph dmap { node [style=filled] label = <dmap> splines = ortho style = filled 129 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!A1</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">inputs</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/format_output.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!A1"] 130 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!A2</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">2</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/format_output-0.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!A2"] 131 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!A3</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">6</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/format_output-1.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!A3"] 132 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!A3:A4</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/format_output-2.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!A3:A4"] 133 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!A4</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">5</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/format_output-3.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!A4"] 134 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!B1</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">Intermediate</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/format_output-4.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!B1"] 135 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!B2</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/format_output-5.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!B2"] 136 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!B3</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/format_output-6.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!B3"] 137 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!B4</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/format_output-7.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!B4"] 138 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!C1</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">outputs</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/format_output-8.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!C1"] 139 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!C2</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/format_output-9.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!C2"] 140 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!C3</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/format_output-10.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!C3"] 141 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!C4</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/format_output-11.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!C4"] 142 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/EXCEL.XLSXDATAA3A4.html">=&#x27;[EXCEL.XLSX]DATA&#x27;!A3:A4</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="='[EXCEL.XLSX]DATA'!A3:A4"] 143 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/(EXCEL.XLSXDATAA2__EXCEL.XLSXDATAA3).html">=(&#x27;[EXCEL.XLSX]DATA&#x27;!A2 + &#x27;[EXCEL.XLSX]DATA&#x27;!A3)</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="=('[EXCEL.XLSX]DATA'!A2 + '[EXCEL.XLSX]DATA'!A3)"] 144 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/(EXCEL.XLSXDATAB2_-_EXCEL.XLSXDATAA3).html">=(&#x27;[EXCEL.XLSX]DATA&#x27;!B2 - &#x27;[EXCEL.XLSX]DATA&#x27;!A3)</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="=('[EXCEL.XLSX]DATA'!B2 - '[EXCEL.XLSX]DATA'!A3)"] 145 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/(EXCEL.XLSXDATAB2__EXCEL.XLSXDATAB3).html">=(&#x27;[EXCEL.XLSX]DATA&#x27;!B2 / &#x27;[EXCEL.XLSX]DATA&#x27;!B3)</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="=('[EXCEL.XLSX]DATA'!B2 / '[EXCEL.XLSX]DATA'!B3)"] 146 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/(EXCEL.XLSXDATAB3__EXCEL.XLSXDATAC2).html">=(&#x27;[EXCEL.XLSX]DATA&#x27;!B3 ^ &#x27;[EXCEL.XLSX]DATA&#x27;!C2)</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="=('[EXCEL.XLSX]DATA'!B3 ^ '[EXCEL.XLSX]DATA'!C2)"] 147 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/(EXCEL.XLSXDATAC2__EXCEL.XLSXDATAA2).html">=(&#x27;[EXCEL.XLSX]DATA&#x27;!C2 * &#x27;[EXCEL.XLSX]DATA&#x27;!A2)</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="=('[EXCEL.XLSX]DATA'!C2 * '[EXCEL.XLSX]DATA'!A2)"] 148 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-27f2d6fc7134948ebbba50fb10fbd018dbca78ca/MAX(EXCEL.XLSXDATAA3A4_EXCEL.XLSXDATAB2).html">=MAX(&#x27;[EXCEL.XLSX]DATA&#x27;!A3:A4, &#x27;[EXCEL.XLSX]DATA&#x27;!B2)</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="=MAX('[EXCEL.XLSX]DATA'!A3:A4, '[EXCEL.XLSX]DATA'!B2)"] 142 -> 132 139 -> 147 147 -> 140 139 -> 146 130 -> 147 131 -> 142 131 -> 143 144 -> 136 146 -> 141 130 -> 143 136 -> 145 133 -> 142 135 -> 148 135 -> 145 135 -> 144 145 -> 139 131 -> 144 132 -> 148 143 -> 135 136 -> 146 148 -> 137 }

To compile, execute, and plot a Excel sub-model you can do the following:

>>> inputs = ["'[EXCEL.XLSX]DATA'!A2"]  # input cells
>>> outputs = ["'[EXCEL.XLSX]DATA'!C2"]  # output cells
>>> func = xl_model.compile(inputs, outputs)
>>> func(2).value[0,0]
4.0
>>> func.plot(view=False)  # Set view=True to plot in the default browser.
SiteMap([(Dispatcher ..., SiteMap())])

digraph dmap { node [style=filled] label = <dmap> splines = ortho style = filled 232 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!A2</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-47f265cac0a153a1217f8a36861816274580296e/format_output.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!A2"] 233 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!A3</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">array([[6]], dtype=object)</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-47f265cac0a153a1217f8a36861816274580296e/format_output-0.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!A3"] 234 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!B2</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-47f265cac0a153a1217f8a36861816274580296e/format_output-1.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!B2"] 235 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!B3</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-47f265cac0a153a1217f8a36861816274580296e/format_output-2.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!B3"] 236 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!C2</TD></TR><TR><TD align="RIGHT" border="1">filter 0</TD><TD align="LEFT" border="1" href="./dispatcher-47f265cac0a153a1217f8a36861816274580296e/format_output-3.html">format_output</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip="'[EXCEL.XLSX]DATA'!C2"] 237 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-47f265cac0a153a1217f8a36861816274580296e/(EXCEL.XLSXDATAA2__EXCEL.XLSXDATAA3).html">=(&#x27;[EXCEL.XLSX]DATA&#x27;!A2 + &#x27;[EXCEL.XLSX]DATA&#x27;!A3)</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="=('[EXCEL.XLSX]DATA'!A2 + '[EXCEL.XLSX]DATA'!A3)"] 238 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-47f265cac0a153a1217f8a36861816274580296e/(EXCEL.XLSXDATAB2_-_EXCEL.XLSXDATAA3).html">=(&#x27;[EXCEL.XLSX]DATA&#x27;!B2 - &#x27;[EXCEL.XLSX]DATA&#x27;!A3)</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="=('[EXCEL.XLSX]DATA'!B2 - '[EXCEL.XLSX]DATA'!A3)"] 239 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-47f265cac0a153a1217f8a36861816274580296e/(EXCEL.XLSXDATAB2__EXCEL.XLSXDATAB3).html">=(&#x27;[EXCEL.XLSX]DATA&#x27;!B2 / &#x27;[EXCEL.XLSX]DATA&#x27;!B3)</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="=('[EXCEL.XLSX]DATA'!B2 / '[EXCEL.XLSX]DATA'!B3)"] 240 [label=end fillcolor=blue shape=egg] 241 [label=start fillcolor=red shape=egg] 241 -> 232 [xlabel=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">start --&gt; &#x27;[EXCEL.XLSX]DATA&#x27;!A2</TD></TR><TR><TD align="RIGHT" border="1">inp_id</TD><TD align="LEFT" border="1">0</TD></TR></TABLE>>] 233 -> 237 236 -> 240 [xlabel=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">&#x27;[EXCEL.XLSX]DATA&#x27;!C2 --&gt; end</TD></TR><TR><TD align="RIGHT" border="1">out_id</TD><TD align="LEFT" border="1">0</TD></TR></TABLE>>] 232 -> 237 234 -> 238 238 -> 235 235 -> 239 239 -> 236 234 -> 239 237 -> 234 233 -> 238 }

3.3. Custom functions

An example how to add a custom function to the formula parser is the following:

>>> import formulas
>>> FUNCTIONS = formulas.get_functions()
>>> FUNCTIONS['MYFUNC'] = lambda x, y: 1 + y + x
>>> func = formulas.Parser().ast('=MYFUNC(1, 2)')[1].compile()
>>> func()
4

4. Next moves

Things yet to do: implement the missing Excel formulas.