ger.s.brett
ger.s.brett

Reputation: 3308

openpyxl: cells do not evaluate

I have this simple python script:

from openpyxl import Workbook

book = Workbook()
sheet = book.active

sheet["A1"]=3

sheet["A2"]=4

sheet["A3"]="=SUM(A1:A2)"

book.save("k_test.xlsx")   

When I open the excel sheet A3 is empty (not calculated). If have to click on the cell and press enter - then the value appears. How can I force excel to calculate the values?

Upvotes: 1

Views: 228

Answers (1)

ger.s.brett
ger.s.brett

Reputation: 3308

In case anyone runs into the same problem. There were two issues:

  • as I was starting from a non English Excel version, I forgot to translate one command to English. So it showed up right lateron in Excel, but there had been an internal error in between that kept it from evaluating it.
  • I had references to an Excel tab that did not exist at the time of inserting the formula. This also leads to the problem that it cannot be evaluated. I had to add the referenced tab, before I could add the formula referring to it.

Upvotes: 1

Related Questions