AttributeError: 'NoneType' object has no attribute 'read' - openpyxl
AttributeError: 'NoneType' object has no attribute 'read' - openpyxl
您好,我在使用此代码时遇到以下错误:
def save_wb(self):
"""
Save the final result file
"""
time.sleep(2)
output_excel_path = self.output_name + ".xlsx"
excel_list_name_delete.append(output_excel_path)
exported = False
while not exported:
try:
self.output_excel.save(output_excel_path)
exported = True
except IOError:
print("Exportation interrupted")
return
错误:
File "C:/Users/Usuario/Desktop/XXX.py", line XXX, in save_wb
self.output_excel.save(output_excel_path)
File "C:\Users\Usuario\Anaconda3\lib\site-packages\openpyxl\workbook\workbook.py", line 367, in save
save_workbook(self, filename)
File "C:\Users\Usuario\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 284, in save_workbook
writer.save(filename)
File "C:\Users\Usuario\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 266, in save
self.write_data()
File "C:\Users\Usuario\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 83, in write_data
self._write_worksheets()
File "C:\Users\Usuario\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 217, in _write_worksheets
self._write_comment(ws)
File "C:\Users\Usuario\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 185, in _write_comment
vml = fromstring(self.workbook.vba_archive.read(ws.legacy_drawing))
AttributeError: 'NoneType' object has no attribute 'read'
据我了解post,openpyxl 代码中存在错误。好像还没有解决。但是,我想知道在不使用 sheet._comments = []
.
的情况下是否存在针对这种情况的可能解决方案
@sommervold 已经提到了解决方案,只需在另一个终端更新您电脑上的最新版本即可。
您好,我在使用此代码时遇到以下错误:
def save_wb(self):
"""
Save the final result file
"""
time.sleep(2)
output_excel_path = self.output_name + ".xlsx"
excel_list_name_delete.append(output_excel_path)
exported = False
while not exported:
try:
self.output_excel.save(output_excel_path)
exported = True
except IOError:
print("Exportation interrupted")
return
错误:
File "C:/Users/Usuario/Desktop/XXX.py", line XXX, in save_wb
self.output_excel.save(output_excel_path)
File "C:\Users\Usuario\Anaconda3\lib\site-packages\openpyxl\workbook\workbook.py", line 367, in save
save_workbook(self, filename)
File "C:\Users\Usuario\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 284, in save_workbook
writer.save(filename)
File "C:\Users\Usuario\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 266, in save
self.write_data()
File "C:\Users\Usuario\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 83, in write_data
self._write_worksheets()
File "C:\Users\Usuario\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 217, in _write_worksheets
self._write_comment(ws)
File "C:\Users\Usuario\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 185, in _write_comment
vml = fromstring(self.workbook.vba_archive.read(ws.legacy_drawing))
AttributeError: 'NoneType' object has no attribute 'read'
据我了解post,openpyxl 代码中存在错误。好像还没有解决。但是,我想知道在不使用 sheet._comments = []
.
@sommervold 已经提到了解决方案,只需在另一个终端更新您电脑上的最新版本即可。