使用xlsxwri自动展开行

2024-04-19 08:12:13 发布

您现在位置:Python中文网/ 问答频道 /正文

当我在excel中单击两行之间的行时,我可以将该列自动扩展到其任何行的最大长度:

enter image description here

当我用xlsxwriter创建一个Excel时,有没有可能预先呈现Excel,使所有行自动扩展到这个最大宽度?在

我知道set_column,但它不符合我的要求,因为您需要给它一个绝对宽度。在


Tags: 宽度columnexcelset行时xlsxwriter
1条回答
网友
1楼 · 发布于 2024-04-19 08:12:13

这是不可能的,因为它不是文件格式的一部分。从XlsxWriterFAQ

Q. Is there an “AutoFit” option for columns?

Unfortunately, there is no way to specify “AutoFit” for a column in the Excel file format. This feature is only available at runtime from within Excel. It is possible to simulate “AutoFit” by tracking the width of the data in the column as your write it.

相关问题 更多 >