Hi Andrew,
Thanks for your question, I appreciate it.
There are three main reasons that I use pywin32 instead of OpenPyXL for the functions mentioned in the article.
First, pywin32 allow us to access Windows API, which I believe we can use most of the function in Excel, while OpenPyXLis a library in the development stage.
There are many popular functions in Excel that can be created with OpenPyXL, like formatting, insert, delete, pivot and copy. One of the OpenPyXL functions I frequently use is to open a new workbook and write the data read with pandas to Excel.
However, OpenPyXL does not fulfil all my requirement for now. There are some functions I need that are not available, for example, paste special which I can paste format only from the existing Excel file to a new Excel file. Although define the style with OpenPyXL is feasible too, but it's easier and faster to copy the format directly.
Second, I am familiar with Excel VBA, the syntax of pywin32 which is similar to Excel VBA is more favourable for me. Furthermore, I can record Macro and refer to the steps whenever I not sure how to write the script for some function.
Third, I can see the results in Excel immediately if I use pywin32.
After all, both OpenPyXL and pywin32 are good libraries to read and write Excel file just in some situation I will select pywin32 instead of OpenPyXL.
Lastly, let me clarify that I use OpenPyXL together with pywin32 and pandas to create an Excel report. I use OpenPyXL to write the pandas DataFrame to the Excel Workbook, then use pywin32 to modify the excel file format and create the pivot table.
Thanks for your message and hope this clears your doubt.
Best regards,
Chu