how can i write text on an existing xlsx file with the help of openpyxl on python?

I used this code to test. I created an empty excel document first. It updated correctly.

import openpyxl 
path = 'pytranslate.xlsx'
wb = openpyxl.load_workbook(path)
ws = wb['Sheet1']
ws.cell(row = 1,column = 1,value = 'need for meas')
val1 = ws['A1'].value
print(val1)
wb.save(path)

Output (excel)

Excel

If your document is not updating, confirm you have correct permissions to the file and folder.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top