我正在尝试使用openpyxl来打开和修改现有的excel工作簿,但我甚至无法在不收到错误的情况下打开该文件。
from openpyxl import load_workbook
ws = load_workbook('PO-Copy.xlsx')
我得到一个很长的TypeError:
Traceback (most recent call last):
File "<module1>", line 6, in <module>
File "C:\Python27\Lib\site-packages\openpyxl\reader\excel.py", line 151, in load_workbook
_load_workbook(wb, archive, filename, read_only, keep_vba)
File "C:\Python27\Lib\site-packages\openpyxl\reader\excel.py", line 224, in _load_workbook
keep_vba=keep_vba)
File "C:\Python27\Lib\site-packages\openpyxl\reader\worksheet.py", line 308, in read_worksheet
fast_parse(ws, xml_source, shared_strings, style_table, color_index)
File "C:\Python27\Lib\site-packages\openpyxl\reader\worksheet.py", line 296, in fast_parse
parser.parse()
File "C:\Python27\Lib\site-packages\openpyxl\reader\worksheet.py", line 84, in parse
dispatcher[tag_name](element)
File "C:\Python27\Lib\site-packages\openpyxl\reader\worksheet.py", line 282, in parse_data_validation
dv = parser(tag)
File "C:\Python27\Lib\site-packages\openpyxl\worksheet\datavalidation.py", line 179, in parser
dv = DataValidation(**element.attrib)
TypeError: __init__() got an unexpected keyword argument 'errorStyle'
有没有其他人遇到此错误?我可以用来继续前进吗?
答案 0 :(得分:1)
在openpyxl 2.1中添加了在现有文件中读取DataValidation的功能,但仅限于Python支持的DataValidation。已经开始完全支持DataValidation,并且可以在https://bitbucket.org/habub68/openpyxl
的2.2分支中找到