How to freeze the top row and the first column using XlsxWriter?

Krzysztof Słowiński picture Krzysztof Słowiński · Jan 30, 2018 · Viewed 9.1k times · Source

I am exporting a pandas DataFrame to Excel, and since it contains a lot of rows and columns, it would be useful to keep the top row and the first column when browsing its contents.

There is a feature present in Excel that allows for freezing the top row and the first column. Is accessible through XlsxWriter when exporting DataFrames to excel?

Answer

Sandeep Lade picture Sandeep Lade · Jan 30, 2018

You can use worksheet.freeze_panes() to achieve this . There are many options for that method. Read http://xlsxwriter.readthedocs.io/worksheet.html#worksheet-freeze-panes to know how to use the method.