Unable to Close Excel file (to send it as an email attachment), because it is being generated from SAP

I am building an automation, in which at one point a Report is generated from SAP in Excel format.
I need to send this report as an email attachment at the end of the process. To send it as an email, it should be closed. So when the report has fewer number of records, UiPath closes it. But when it has more records it is not getting closed. Probably because SAP is still working on the file.
Kindly suggest what I can do to check the file is closed before sending the mail…I have tried many methods: