Reputation: 161
I am opening an Excel with openpyxl library, however it is saving the Excel in read - only mode
I tried the answer of this question:
Openpyxl does not close Excel workbook in read only mode
wb._archive.close()
but it give me AttributeError: 'Workbook' object has no attribute '_archive'.
I am working with the following code:
wb = openpyxl.Workbook()
sheet1 = wb.create_sheet("mysheet", 0)
sheet1 = wb["mysheet"]
sheet1.cell(row=1, column=1).value = '123'
sheet1.cell(row=1, column=2).value = 'summary'
wb.save(filename) /*filename has the adress of xlsx*/
The Excel file is created without problem, however it is in 'read only' mode. How can I prevent this? Is there an option for the save or create method to avoid read only mode?
Thanks for your help.
Upvotes: 1
Views: 3717
Reputation: 19507
I suspect the problem is simply one of file permissions in Windows. Read-only mode in openpyxl have nothing to do with this and is not relevant here. Check the permissions and ownership of the file you've created and that it is not opened by any other program or process.
Upvotes: 1