Error: Attributeerror: 'Nonetype' Object has no attribute 'write'

Asked

Viewed 172 times

0

I performed some operations on a dataframe by the pandas but I need to keep some cells of an xlsx with a formula. For this I imported a library xlsxwriter but I am not able to evolve my script

import xlsxwriter as xw
arquivo = 'teste.xlsx'
workbook = xw.Workbook(arquivo)
worksheet = workbook.get_worksheet_by_name('Planilha1')
worksheet.write("N2", "=SUM(E2+H2)")

Only when I run that line worksheet.write("N2", "=SUM(E2+H2)") i get the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-50-a185173abe26> in <module>
----> 1 ws.write("N2", "=SUM(E2+H2)")

AttributeError: 'NoneType' object has no attribute 'write'

And I’m not sure how to fix it. Can you help me?

  • You should find another library if you want to write to an existing spreadsheet. This get_worksheet_by_name is only for files that xlswriter has written.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.