olopost
olopost

Reputation: 53

How to refresh Excel Formula at read

I want to use Excel sheet in pandas. The excel sheet has some automatic calculate formula base on the date of the day.

There are any way to update Excel formula before or during the open of Excel file in pandas.

Upvotes: 1

Views: 5590

Answers (1)

zipa
zipa

Reputation: 27889

This should work:

import pandas as pd
import win32com.client

office = win32com.client.Dispatch("Excel.Application")
wb = office.Workbooks.Open(your_file_path)
wb.RefreshAll()
wb.Save()
wb.Close()
df = pd.read_excel(your_file_path) #updates should be applied

Upvotes: 3

Related Questions