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'
engine='xlsxwriter'
topd.ExcelWriter()
otherwise Pandas could substitute OpenPyXL if that is available and XlsxWriter is not. Hence the missing method error. If you aren't using XlsxWriter specific methods then it doesn't matter which engine is used. – Ailssa