How To Refresh Excel Using Python
I need to evaluate a function within excel using python right after writing that function into excel with xlsx writer or openpyxl. I need to pull the number generated by this funct
Solution 1:
I figured it out. I didn't realize before that you can use win32com to write in excel as well.
import win32com.client as w3c
ex_file = w3c.DispatchEx('Excel.Application')
wb = ex_file.Workbooks.Add()
ws = wb.Worksheets.Add()
ws.Name = 'Test'
ws.Range('A1:A1') = <function>
wb.RefreshAll()
cell_val = ws.Range('A1:A1').value
print(cell_val)
wb.SaveAs(<file name.xlsx>)
ex_file.Quit()
Post a Comment for "How To Refresh Excel Using Python"