Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does a 'WriteOnlyWorksheet' object have no attribute '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?

like image 741
Lmorj Avatar asked Aug 30 '26 02:08

Lmorj


1 Answers

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

like image 112
user2357112 supports Monica Avatar answered Aug 31 '26 15:08

user2357112 supports Monica



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!