I try to load excel file for change some values inside it and for read some formulas. if I get a new excel file (which didn't save with openpyxl), I can read formulas result with code:
from openpyxl import *
wb = load_workbook(filename="test1.xlsx",data_only=True)
sheet1 = wb.active
print(sheet1["b9"].value)
### b9 formul is '=SUM(A1+A2+A3)' that's also working in excel.
###output is :37
But, If a change something inside file as belown code:
from openpyxl import *
wb =load_workbook(filename="test1.xlsx")
sheet = wb.active
sheet["A1"]=42
sheet["A2"]=33
sheet["A3"]=22
wb.save(filename="test1.xlsx")
wb = load_workbook(filename="test1.xlsx",data_only=True)
sheet1 = wb.active
print(sheet1["b9"].value)
##output is : None
When I check excel file everythings seems good. formule is right, columns changed, but when I try to read excel formulas with python, I can't see the result, it turns None, if removed data_only=True from workbook also I can see formulas. What's wrong with my code.