Call save,Prompt list index out of range
Created originally on Bitbucket by xiaoqi7s
import openpyxl path = r'C:\Users\hcb\Desktop\test.xlsx' wb = openpyxl.load_workbook(path) wb.save('test.xlsx')
Traceback (most recent call last): File "D:/python3/test1/myPackge/test2.py", line 4, in wb.save('test.xlsx') File "C:\Python36\lib\site-packages\openpyxl\workbook\workbook.py", line 342, in save save_workbook(self, filename) File "C:\Python36\lib\site-packages\openpyxl\writer\excel.py", line 267, in save_workbook writer.save(filename) File "C:\Python36\lib\site-packages\openpyxl\writer\excel.py", line 248, in save self.write_data() File "C:\Python36\lib\site-packages\openpyxl\writer\excel.py", line 81, in write_data self._write_worksheets() File "C:\Python36\lib\site-packages\openpyxl\writer\excel.py", line 197, in _write_worksheets xml = ws._write() File "C:\Python36\lib\site-packages\openpyxl\worksheet\worksheet.py", line 870, in _write return write_worksheet(self) File "C:\Python36\lib\site-packages\openpyxl\writer\worksheet.py", line 99, in write_worksheet cols = ws.column_dimensions.to_tree() File "C:\Python36\lib\site-packages\openpyxl\worksheet\dimensions.py", line 230, in to_tree obj = col.to_tree() File "C:\Python36\lib\site-packages\openpyxl\worksheet\dimensions.py", line 182, in to_tree attrs = dict(self) File "C:\Python36\lib\site-packages\openpyxl\worksheet\dimensions.py", line 51, in iter value = getattr(self, key, None) File "C:\Python36\lib\site-packages\openpyxl\styles\styleable.py", line 95, in get return coll.names[idx] IndexError: list index out of range