#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:
- Python Openyxl Error: AttributeError: ‘int‘ object has no attribute ‘upper‘ [How to Solve]
- [Solved] pandas ExcelWrite AttributeError: ‘NoneType‘ object has no attribute ‘group‘
- [Solved] AttributeError: ‘DataParallel‘ object has no attribute ‘save‘
- [Solved] AttributeError: ‘DataFrame‘ object has no attribute ‘tolist‘
- [Solved] AttributeError: ‘PngImageFile‘ object has no attribute ‘imshow‘
- AttributeError: DatetimeProperties object has no attribute
- [Solved] AttributeError: ‘DataFrame‘ object has no attribute ‘map‘
- [Solved] vpython: AttributeError: ‘box‘ object has no attribute ‘idx‘
- [Solved] AttributeError: ‘NoneType‘ object has no attribute ‘astype‘
- [Solved] AttributeError: DataFrame object has no attribute’xxx’
- [Solved] AttributeError: ‘str‘ object has no attribute ‘decode‘
- [Solved] AttributeError: ‘NoneType‘ object has no attribute ‘append‘
- [Solved] Paramiko error: AttributeError: ‘NoneType’ object has no attribute ‘time’
- [Solved] django AttributeError: ‘UserComment‘ object has no attribute ‘save‘
- [Solved] Pycharm error: attributeerror: ‘Htmlparser’ object has no attribute ‘unescape’
- [Solved] AttributeError: ‘str‘ object has no attribute ‘decode‘
- [Solved] Networkx Error: Attributeerror: ‘graph’ object has no attribute ‘node’
- [Solved] AttributeError: ‘HTMLWriter‘ object has no attribute ‘_temp_names‘
- How to Solve Python AttributeError: ‘module’ object has no attribute ‘xxx’
- [Modified] AttributeError: ‘socket‘ object has no attribute ‘ioctl‘ python linux