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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 05:06:29  来源:igfitidea点击:

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

pythonexcelpandasdataframexlsxwriter

提问by Krzysztof S?owiński

I am exporting a pandas DataFrameto 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 XlsxWriterwhen 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以了解如何使用该方法。