Is there a way to edit/save an opening (in excel) xlsx file?

1.5k views Asked by At

I want to do something like this:

import openpyxl as x

wb = x.load_workbook(filename)

# do some edit to the workbook

wb.save(filename)

The file specified by the filename is opening in Excel. Excel is locking the file so I will get permission denied error running the above code. Is there a way to edit/save it?

1

There are 1 answers

5
Vikas Ojha On
from openpyxl import load_workbook
ifile = 'Whales.xlsx'

wb = load_workbook(filename=ifile)

# do some edit to the workbook
wb.save(ifile)