Neither of these process, as would be expected reading the documentation:
worksheet.close()
workbook.close()
Is there a way to close files once done in openpyxl? Or is it handled automatically when the program quits? I dont want to leave spreadsheets left hanging in memory.
well you can take a look at the source code, Im currently using 1.5.5 as such
it looks like yes it does close the archive, when we load a workbook, how about when we save it?
it looks like it also closes the archive when we save it.
Fundamentally we read an excel workbook into memory from a file which is closed afterwards, make updates, if we don't save it, the changes presumably are lost, if we save it, the file is closed after writing.
you can save your changes using
wb.save(filename = dest_filename)
as forhandled automatically
when readin or writing to a file then yes its closed after operation but having openpyxl automatically save your changes then no being thatclass Workbook(object):
doesn't have__del__
then nothing is called when that object is deleted or garbage collected, again this is for1.5.5
the current version is1.5.8
as of this writing, I doubt to much has changed.