1
votes

I have a workbook that I am modifying with openpyxl.

After I run the code, I can see the formula being written in the excel file but it prints an empty df. (if I open the excel file and manually click save, the printed df has the right data).

Can anyone explain how to allow the read_excel to read the value in that cell instead of the formula?

from openpyxl import load_workbook
import pandas as pd


file_path = "Test.xlsx"
workbook = load_workbook(file_path)
workbook["Temp"]["A1"] = f"=SUM(2+2)"
workbook.save(file_path)
df = pd.read_excel(file_path, header=None)
print(df)  # empty df??