gpt4 book ai didi

python - 使用 Python 的 xlrd 和 xlutils 保留 Excel 格式的问题

转载 作者:行者123 更新时间:2023-11-28 20:21:21 29 4
gpt4 key购买 nike

<分区>

简而言之,我想将一个 Excel 文件的所有格式保留到另一个文件中。然而,尽管使用了 formatting_info=True 标志,但格式只会出现在已更改行中所有未更改的单元格中。有什么建议吗?

import xlrd, xlutils
from xlrd import open_workbook
from xlutils.copy import copy

inBook = xlrd.open_workbook(r"path/to/file/format_input.xls", formatting_info=True, on_demand=True)
outBook = xlutils.copy.copy(inBook)

outBook.get_sheet(0).write(0,0,'changed!')
outBook.save(r"path/to/file/format_output.xls")

在此输入图片描述

enter image description here

enter image description here

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