How to automatically adjust Excel column widths in openpyxl
Want to share your content on python-bloggers? click here.
Excel’s popularity stems from its user-friendly data formatting and presentation capabilities. Take, for example, the nuisance of narrow columns. Resolving this issue in Excel is as simple as selecting the affected columns and double-clicking on any one of them:
Python does present unique strengths to Excel, but visual formatting of the data can be difficult. It’s still, however, possible with the help of openpyxl
:
Open the autofit_example.xlsx
workbook created in the previous notebook and you’ll see all the content in the columns is easily visible:
What Excel automation tasks have you found particularly difficult in Python? Have you thought about defining functions for any other typical tasks? Let me know in the comments.
Want to share your content on python-bloggers? click here.