gpt4 book ai didi

python - 如何在xlsxwriter中自动设置列宽

转载 作者:太空狗 更新时间:2023-10-30 00:48:52 25 4
gpt4 key购买 nike

我一直对使用 worksheet.set_column 感到困惑。是否有可能自动设置所有列的宽度?

模拟它的 Python 函数是什么? (仅使用 xlsxwriter 库):

def autofit(filename, worksheet_name):
# ???

最佳答案

Is there any possibility of setting the width of all columns automatically?

不幸的是,不是。

来自XlsxWriter FAQ :

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" in your application by tracking the maximum width of the data in the column as your write it and then adjusting the column width at the end.

关于python - 如何在xlsxwriter中自动设置列宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35728245/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com