如何删除 Auto Filter 之后的可见行,不包括标题行?

How to delete the visible rows after Auto Filter , excluding the heading row?

在Excel Interop中,设置一个Range.Autofilter()后,我需要删除除第一行以外的所有可见行。由于第一行是 sheet 的标题行。 谢谢.

Excel.Application objexcel = new Microsoft.Office.Interop.Excel.Application();
Excel.Workbook xlBook = objexcel.Workbooks.Open(filename);
Excel.Worksheet xlSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlBook.Worksheets.get_Item(1);
range = xlSheet.UsedRange;
Excel.Range last =xlSheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell, Type.Missing);
range.get_Range("A2", last).Delete(XlDeleteShiftDirection.xlShiftUp);

这有效。