delete excel worksheets programatically

have an excel workbook with many, many sheets. I want to delete all the sheets except for three of them.

specifically, i would like to know if there is a way to remove the sheets using sheet name instead of ordinals (sheet number).

i am using excel interop and C# to work with Excel.

any code / ideas would be helpful.

        Microsoft.Office.Interop.Excel.Application xlApp = null;
        Excel.Workbook xlWorkbook = null;
        Excel.Sheets xlSheets = null;
        Excel.Worksheet xlNewSheet = null;


xlApp.DisplayAlerts = false;
for (int i = xlApp.ActiveWorkbook.Worksheets.Count; i > 0 ; i--)
    Worksheet wkSheet = (Worksheet)xlApp.ActiveWorkbook.Worksheets[i];
    if (wkSheet.Name == "NameOfSheetToDelete")
xlApp.DisplayAlerts = true;

Need Your Help

htaccess mod_rewrite:- products.php?cat=1 to /myfolder1/myproduct1/

php .htaccess mod-rewrite seo

I've got a url type:- which I am able to rewrite to:- using the following .htaccess rule:- RewriteRule ^myproduct1$