openpyxl read formula value without changing formu

2019-08-04 00:35发布

问题:

I want to read the formula value in an xlsx file, write the value in another cell and store the xlsx file.

I'm using the data_only mode

excelDoc = openpyxl.load_workbook(clientFile, data_only=True)

to read the formula value. But when I save the file all formulas are overriden by their values.

How can I prevent that?

回答1:

You can't. You can either have the values or the formulae.