python xlutils:formatting_info=True 尚未实现

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13892307/
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-08-18 09:52:20  来源:igfitidea点击:

python xlutils : formatting_info=True not yet implemented

pythonpython-2.7xlrdxlwtxlutils

提问by user1891854

I've got simple code to copy files with xlutils, xlrd, xlwt (downloaded new libraries from python-excel.org) with not loosing formatting. I've got an error as below:

我有简单的代码可以使用 xlutils、xlrd、xlwt(从 python-excel.org 下载新库)复制文件,而不会丢失格式。我有一个错误如下:

from xlwt.Workbook import *
from xlwt.Style import *
from xlrd import open_workbook
from xlutils.copy import copy
import xlrd

style = XFStyle()
rb = open_workbook('file_master.xlsx', formatting_info=True)
wb = copy(rb.get_sheet(0))

new_book = Workbook()
w_sheet = wb.get_sheet(0)
w_sheet.write(6,6)

wb.save('new_file_master.xls')

Error:

错误:

 raise NotImplementedError("formatting_info=True not yet implemented")
NotImplementedError: formatting_info=True not yet implemented

Could you please help me how to work around this or rather make it work?

你能帮我解决这个问题还是让它发挥作用?

回答by Amelse Etomer

According to this threadthe flag

根据这个线程的标志

formatting_info=True

is only working for xls-files, but not for xlsx yet (Version xlrd-0.8.0).

仅适用于 xls 文件,但不适用于 xlsx(版本 xlrd-0.8.0)。

As a workaround you could convert the workbook to xls using Excel or OpenOffice.

作为一种解决方法,您可以使用 Excel 或 OpenOffice 将工作簿转换为 xls。

It seems that a commandline conversion from xlsx to xls is possible using Unoconvon Linux, Windows and MacOSX.

似乎可以在 Linux、Windows 和 MacOSX 上使用Unoconv进行从 xlsx 到 xls 的命令行转换。