I'm trying to refresh excel pivot table using openpyxl library.
data sheet
Image may be NSFW.
Clik here to view.
result sheet
Image may be NSFW.
Clik here to view.
If I update values in data sheet, the pivot table in result sheet gets updated only when I reopen the excel file. I cannot get the updated value in my new_df variable of my python code.I need to use the new_df variable for in my further code. So, reopening the file to refresh the data won't help me.
Is there any other workaround to resolve my issue in Linux machine?
Here is the code
from openpyxl import load_workbookimport pandas as pdwb = load_workbook("test_excel_file2.xlsx")ws = wb["result"]pivot= ws._pivots[0]pivot.cache.enableRefresh = Truepivot.cache.refreshOnLoad = Truewb.save(excel_filepath)new_df = pd.read_excel("test_excel_file2.xlsx", sheet_name=calc_sheet)print(new_df)