Spreadsheet getting stuck

I am using data rows in MS Excel as a data table in UiPath. Sometimes when the work flow is interrupted and I have to restart it the spreadsheet can not be used as it is saying that it is in use by another program. I have to “Save As” to another name in order to continue using the spreadsheet. Even after the program is complete I can not edit or delete the spreadsheets that get stuck. Any ideas?

Try to invoke the below methods at the end of your process or whenever there is an interruption(may be in catch).