My program generates an Excel in a loop and sends it by Email. In each loop iteration it should overwrite the Excel, but the Excel is still used by the old Excel process which is why I get a System.IO.IOException exception.
Here is the process:
Here is the Code:
if(File.Exists(PfadXlsx)) File.Delete(PfadXlsx);
mExcel.Visible = true;
mExcelWs.SaveAs(PfadXlsx, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault, missing, missing, false, false, false, missing, missing, missing); // Datei speichern
mExcelWb.Close(true, missing, missing);
mExcel.Application.Quit();
mExcel.Quit();
mExcel == Excel.Application mExcelWB == Excel.Workbook
mExcel==Excel.Worksheet missing == type.missing
No comments:
Post a Comment