[Solved] AttributeError WriteOnlyWorksheet object has no attribute cell

#Importing the openpyxl module
import openpyxl

## Create a workbook##
#1. Create a workbook
workbook=openpyxl.Workbook('.. /Excel_Data/data1.xlsx')
#2. create a sheet page (form)
sheet_name=workbook.create_sheet('sheet1')
#3. Write a data
sheet_name.cell(row=2,column=2,value="data written")
#4. Save
workbook.save('../Excel_Data/data1.xlsx')

Error in execution result:

AttributeError: ‘WriteOnlyWorksheet’ object has no attribute ‘cell’

reason:

The problem should be that the workbook cannot be written at the same time when it is created, so you can create and save the workbook first, and then open it, and the data can be written.

Read More: