on-internet
← Community

Is there a way to auto-adjust Excel column widths with pandas.ExcelWriter?

Stack Overflow ·

I am being asked to generate some Excel reports. I am currently using pandas quite heavily for my data, so naturally I would like to use the pandas.ExcelWriter method to generate these reports. However the fixed column widths are a problem. The code I have so far is simple enough. Say I have a dataframe called df: writer = pd.ExcelWriter(excel_file_path, engine='openpyxl') df.to_excel(writer, sheet_name="Summary") I was looking over the pandas docs, and I don't really see any options to set column widths. Is there a trick to make it such that the columns auto-adjust to the data? Or is there so

Comments

Sign in or sign up to comment and upvote.

No comments yet.