问题
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:
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?
回答1:
According to this thread the flag
formatting_info=True
is only working for xls-files, but not for xlsx yet (Version xlrd-0.8.0).
As a workaround you could convert the workbook to xls using Excel or OpenOffice.
It seems that a commandline conversion from xlsx to xls is possible using Unoconv on Linux, Windows and MacOSX.
来源:https://stackoverflow.com/questions/13892307/python-xlutils-formatting-info-true-not-yet-implemented