.Net Excel Interop Deleting a worksheet

Melursus picture Melursus · Mar 24, 2009 · Viewed 44.7k times · Source

I'm trying to delete a worksheet from a excel document from a .Net c# 3.5 application with the interop Excel class (for excel 2003).

I try many things like :

Worksheet worksheet = (Worksheet)workbook.Worksheets[1];
worksheet.Delete();

It's doesn't work and doesn't throw any error ...

Answer

Melursus picture Melursus · Mar 24, 2009

After more than one hour looking I found the answer:

xlApp.DisplayAlerts = false;
worksheet.Delete();
xlApp.DisplayAlerts = true;