l******9 发帖数: 579 | 1 【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: delete sheets from Excel workbook in C#
发信站: BBS 未名空间站 (Fri May 22 14:08:38 2015, 美东)
I need to delete some sheets from an Excel workbook in C#.
But, my code does not work.
// **aDeleteList** hold the sheets that need to be deleted from the
workbook wbk
static void delete_sht(ref MsExcel.Workbook wbk, List
aDeleteList)
{
MsExcel.Sheets my_st = wbk.Sheets;
foreach (MsExcel.Worksheet s in my_st)
{
if (aDeleteList.Contains(s.Name))
s.Delete();
int t1 = my_st.Count;
int t = wbk.Sheets.Count;
}
}
The values of t and t1 do not change no matter
s.Delete()
has been executed.
Any help would be appreciated. |
|