|
|
|
|
|
|
l******9 发帖数: 579 | 1 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. | z****0 发帖数: 4413 | 2 你从来不说中文, 是烙印吧
【在 l******9 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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) : {
| l******s 发帖数: 3045 | 3 stackoverflw is a better place to go for such questions.
【在 l******9 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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) : {
|
|
|
|
|
|
|