我正在尝试使用Openpyxl将数据写入现有的excel文件,但是在加载文件时出现类型错误。
这是我的代码:
from openpyxl import load_workbook
wb = load_workbook('file.xlsx')
DriverTableSheet = wb.get_sheet_by_name('sheet1')
DriverTableSheet.cell(row=1, column=2).value="value"
wb.save('file.xlsx')
这是错误:
Traceback (most recent call last):
File "modify.py", line 11, in <module>
wb = load_workbook('file.xlsx')
File "C:\Python34\lib\site-packages\openpyxl-2.4.0b1-py3.4.egg\openpyxl\reader\excel.py", line 240, in load_workbook
parser.assign_names()
File "C:\Python34\lib\site-packages\openpyxl-2.4.0b1-py3.4.egg\openpyxl\packaging\workbook.py", line 74, in assign_nam
es
sheet = self.wb._sheets[defn.localSheetId]
TypeError: list indices must be integers, not NoneType