How to save in openpyxl without losing formulae?

110 views
Skip to first unread message

ingles...@gmail.com

unread,
Sep 24, 2015, 8:23:58 PM9/24/15
to openpyxl-users
Because I need to parse and then use the actual data in cells, I open an xlsm in openpyxl with data_only = True.

This has proved very useful. Now though, having the same need for an xlsm that contains formuale in cells, when I then save my changes, the formulae are missing from the saved version.

Are data_only = True and formulae mutually exclusive? If not, how can I access the actual value in cells without losing the formulae when I save?

When I say I lose the formulae, it seems that the *results* of the formulae (sums, concatenattions etc.) get preserved. But the actual formulaes themselves are no longer displayed when a cell is clicked.

ingles...@gmail.com

unread,
Sep 24, 2015, 8:42:44 PM9/24/15
to openpyxl-users, ingles...@gmail.com

UPDATE:

To confirm whether or not the formulaes were being preserved or not, I've re-opened the saved xlsm, this time with data_only left as False. I've checked the value of a cell that had been constructed using a formula. Had formulae been preserved, opening the xlsm with data_only set to False should have return the formula. But it returns the actual text value (which is not what I want).

Charlie Clark

unread,
Sep 25, 2015, 2:38:48 AM9/25/15
to openpyx...@googlegroups.com
Am .09.2015, 02:23 Uhr, schrieb <ingles...@gmail.com>:

> Are *data_only = True* and formulae mutually exclusive?

Yes, and this is covered in the documentation.

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
Reply all
Reply to author
Forward
0 new messages