Member-only story
Automation with PyWin32
Automate Pivot Table with Python (Create, Filter and Extract)
Automate Pivot Table and extract data from the filtered Pivot Table. Save your time for a cup of tea.
In Automate Excel with Python, the concepts of the Excel Object Model which contain Objects, Properties, Methods and Events are shared. The tricks to access the Objects, Properties, and Methods in Excel with Python pywin32
library are also explained with examples.
Now, let us leverage the automation of Excel report with Pivot Table, one of the most wonderful functions in Excel!
Why PyWin32?
You may curious why don’t we use pandas.DataFrame.pivot
or pandas.DataFrame.pivot_table
from pandas
library instead? It’s a built-in library that we don’t even need to install.
Well, the two pandas
functions mentioned above can create the Pivot Table easily, but if you are preparing an Excel report which will be accessed by other domain users, the hard-coded pivot table created may not favour them as they cannot modify the Pivot Table Fields.