I am trying to write text to an excel I am following this post. This was working earlier but now it is not. I get:
Error:
line 122, in <module>
worksheet.write(0, 11, 'HI')
AttributeError: 'Worksheet' object has no attribute 'write'
df1
A E
c d
c D
Code:
writer = pd.ExcelWriter("C:\\33.xlsx")
df1.to_excel(writer, startrow=0, startcol=0, index = False)
worksheet = writer.sheets['Sheet1']
worksheet.write(0, 11, 'YO')
worksheet.write(1, 11, 'HI')
I have tried also:
import xlrd
import xlwt
from xlutils.copy import copy
import os.path
rb = xlrd.open_workbook('C:\\13.xlsx',formatting_info=True)
r_sheet = rb.sheet_by_index(0)
wb = copy(rb)
sheet = wb.get_sheet(0)
sheet.write(5,2,"string")
wb.save('C:\\13.xlsx')
I get:
with open(filename, "rb") as f:
OSError: [Errno 22] Invalid argument: 'C:\\13.xlsx"'
How do I fix AttributeError: 'Worksheet' object has no attribute 'write'
The reason it gives: AttributeError: 'Worksheet' object has no attribute 'write'
Is because I realised I have not installed xlsxwriter on this pc.
pip install xlsxwriter
Now it works.