ASP.NET : Fermer correctement les process MS Office
Par Ronan le jeudi, octobre 26 2006, 17:37 - Plateforme .NET - Lien permanent
Clore correctement les processus lancés pour les objets instanciés via les APIs de Excel.
Excel.Workbook oBook;
Excel.Worksheet oSheet;
Excel.Application oExcelApp = new Excel.Application();
oExcelApp.Visible = False
oExcelApp.DisplayAlerts = False
oBook = oExcelApp.Workbooks.Add();
oBook.Sheets.Add();
oSheet = oBook.Sheets(0);
if (oBook != null)
{
oBook.Close(true, strTemplate, oRien)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook)
oBook = null;
}
if (oSheet != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSheet);
oSheet = null;
}
if (oExcelApp != null)
{
oExcelApp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcelApp);
oExcelApp = null;
}
Commentaires