为什么"WriteOnlyWorksheet"对象没有属性"cell"? [英] Why does a 'WriteOnlyWorksheet' object have no attribute 'cell'?
本文介绍了为什么"WriteOnlyWorksheet"对象没有属性"cell"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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")
当我尝试在单元格中书写时,我收到此错误.
When i try and write in the cell, I receive this error.
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'
我想知道是否有人知道为什么会这样吗?
I was wondering if anybody knew why this was the case?
推荐答案
来自仅写模式文档:
在只写工作簿中,只能用
append()
添加行.用cell()
或iter_rows()
不能在任意位置写入(或读取)单元.
In a write-only workbook, rows can only be added with
append()
. It is not possible to write (or read) cells at arbitrary locations withcell()
oriter_rows()
.
这篇关于为什么"WriteOnlyWorksheet"对象没有属性"cell"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文