pandas 如何使用 XlsxWriter 冻结顶行和第一列?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48519337/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to freeze the top row and the first column using XlsxWriter?
提问by Krzysztof S?owiński
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.
我正在将 Pandas 导出DataFrame
到 Excel,由于它包含很多行和列,因此在浏览其内容时保留第一行和第一列会很有用。
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?
Excel 中有一项功能可以冻结顶行和第一列。将 DataFrames 导出到 excelXlsxWriter
时是否可以访问?
回答by Sandeep Lade
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-panesto know how to use the method.
您可以使用它worksheet.freeze_panes()
来实现这一点。这种方法有很多选择。阅读http://xlsxwriter.readthedocs.io/worksheet.html#worksheet-freeze-panes以了解如何使用该方法。