python - 为什么 'WriteOnlyWorksheet' 对象没有属性 'cell' ?

标签 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")

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

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'

我想知道是否有人知道为什么会这样?

最佳答案

来自write-only mode docs :

In a write-only workbook, rows can only be added with append(). It is not possible to write (or read) cells at arbitrary locations with cell() or iter_rows().

关于python - 为什么 'WriteOnlyWorksheet' 对象没有属性 'cell' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44313365/

相关文章:

xcode - Swift - 无法在我的 tableView 上使用 "registerNib"添加自定义单元格

python - 将行高应用于第 7 行及其之后的所有行

python - Django 字符串换行

matlab - 如何在 MATLAB 中从网格中创建字符串单元格?

具有积分函数的python拟合曲线

excel - 比较Excel中的两个单元格并返回匹配的字符数

python - 从 openpyxl.styles 导入样式,字体导入错误 : cannot import name Style

python - 在 openpyxl 中使用富文本编辑工作簿

python - 我如何使用 lxml , python 解析 html

python - 在 asyncio 模块中完成一个任务列表后,如何提交另一个任务列表?