vinci1it2000 / formulas

Excel formulas interpreter in Python.
https://formulas.readthedocs.io/
European Union Public License 1.1
342 stars 75 forks source link

Save the model #95

Closed Omidbadrr closed 2 years ago

Omidbadrr commented 2 years ago

Hi, Is it possible to add a feature to save the "xl_model" ( xl_model = formulas.ExcelModel().loads(fpath).finish() ) on a disk and only load it later on if we want to use it instead of running formulas.ExcelModel()

vinci1it2000 commented 2 years ago

Yes sure. Follows a code example:

>>> import formulas
>>> import json
>>> xl_model = formulas.ExcelModel().load('excel.xlsx')
>>> with open('model.json', 'w') as f: 
...     json.dump(xl_model.to_dict(), f)
>>> xl_model = formulas.ExcelModel()
... with open('model.json') as f: 
...     xl_model.from_dict(json.load(f))