Why does a 'WriteOnlyWorksheet' object have no attribute 'cell'?

此生再无相见时 提交于 2019-12-13 22:45:07

问题


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?


回答1:


From the 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().



来源:https://stackoverflow.com/questions/44313365/why-does-a-writeonlyworksheet-object-have-no-attribute-cell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!