Python 为什么a';WriteOnly工作表';对象没有属性';单元格';?

Python 为什么a';WriteOnly工作表';对象没有属性';单元格';?,python,cell,openpyxl,Python,Cell,Openpyxl,当我尝试在单元格中写入时,收到此错误 import openpyxl wb=openpyxl.Workbook("multiplication.xlsx") wb.create_sheet() sheet=wb.get_active_sheet() sheet.cell(column=6, row=4).value= 5 wb.save("multiplication.xlsx") 回溯(最近一次呼叫最后一次): 文件“/Users/bjg/Desktop/excel2.py”,第8行,

当我尝试在单元格中写入时,收到此错误

import openpyxl

wb=openpyxl.Workbook("multiplication.xlsx")
wb.create_sheet()
sheet=wb.get_active_sheet()

sheet.cell(column=6, row=4).value= 5

wb.save("multiplication.xlsx")
回溯(最近一次呼叫最后一次):
文件“/Users/bjg/Desktop/excel2.py”,第8行,在
表.单元格(列=6,行=4).值=5
AttributeError:“WriteOnlySheet”对象没有属性“cell”
我想知道是否有人知道为什么会这样

在只写工作簿中,只能使用
append()
添加行。使用
cell()
iter\u rows()在任意位置写入(或读取)单元格是不可能的

从:

在只写工作簿中,只能使用
append()
添加行。使用
cell()
iter\u rows()在任意位置写入(或读取)单元格是不可能的

而不是做:

Traceback (most recent call last):
  File "/Users/bjg/Desktop/excel2.py", line 8, in <module>
    sheet.cell(column=6, row=4).value= 5
AttributeError: 'WriteOnlyWorksheet' object has no attribute 'cell'
只要做:

wb=openpyxl.Workbook("multiplication.xlsx")
然后,最后使用以下命令保存:

wb=openpyxl.Workbook()
而不是做:

Traceback (most recent call last):
  File "/Users/bjg/Desktop/excel2.py", line 8, in <module>
    sheet.cell(column=6, row=4).value= 5
AttributeError: 'WriteOnlyWorksheet' object has no attribute 'cell'
只要做:

wb=openpyxl.Workbook("multiplication.xlsx")
然后,最后使用以下命令保存:

wb=openpyxl.Workbook()