Excel Memory Issues

Yes, every time a file is read an instance of Excel is open and then when read is successful it is being closed. This is the method that I use to do that:

def ExitExcel(xlApp, wb, ws):
	# clean up before exiting excel, if any COM object remains
	# unreleased then excel crashes on open following time
	def CleanUp(_list):
		if isinstance(_list, list):
			for i in _list:
				Marshal.ReleaseComObject(i)
		else:
			Marshal.ReleaseComObject(_list)
		return None
		
	xlApp.ActiveWorkbook.Close(False)
	xlApp.ScreenUpdating = True
	CleanUp([ws,wb,xlApp])
	return None

You don’t have to call xlApp.Quit() if workbook was closed properly.

If there was an exception thrown during this process the open excel app will linger behind. In that case it makes sense to collect it and call Quit() on it like so:

except:
		xlApp.Quit()
		Marshal.ReleaseComObject(xlApp)
		# if error accurs anywhere in the process catch it
		import traceback
		errorReport = traceback.format_exc()
		pass

I do that in the exception handling part of ReadExcel node.

If you are experiencing a massive slowdown, I am sure I can relate. I get it too, but that’s because every time you hit run Dynamo loads in all of the libraries that are being used by the Python node implementation. There is a massive performance hit on that side of things, but there is nothing I can do about that.

I think @Dimitar_Venkov might know more about this slowness associated with Python implementation in Dynamo. I haven’t looked at it closely.