Skip to content
Advertisement

Dataframe to Excel, with no border formatting, and auto column width

In writing dataframe to Excel spreadsheet, I want the file to have no border on the first row and column width to be auto adjusted.

With the old package xlwt and xlrd, I can read the file from Pandas produced, to a new file with no border on the header. But it’s .xls (not .xlsx) format.

I can’t make the column width auto adjusted (according to the content of the cells).

enter image description here

The lines looked tedious and troublesome.

What is the Pandas way to do so?

JavaScript

Advertisement

Answer

For the first question, use:

JavaScript

Demonstration:

JavaScript

enter image description here

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement