我怎么能确定有多少工作表中有一个Excel工作簿? [英] How can I determine how many worksheets there are in an Excel workbook?
本文介绍了我怎么能确定有多少工作表中有一个Excel工作簿?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在此先感谢您的帮助。我想通过工作簿中的所有工作表循环。不幸的是,我不知道有多少工作表有在给定的工作簿。现在我用下面的方法,通过所有工作表列举:
thanks in advance for your help. I want to loop through all worksheets in a workbook. Unfortunately, I don't know how many worksheets there are in a given workbook. Right now I use the following technique to enumerate through all worksheets:
Excel.Worksheet xlWorkSheet1;
xlWorkSheet1 = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
Excel.Worksheet xlWorkSheet2;
xlWorkSheet2 = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(2);
Excel.Worksheet xlWorkSheet3;
xlWorkSheet3 = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(3);
有没有返回工作簿中的工作表数的方法是什么?
Is there a method that returns the number of worksheets in a workbook?
推荐答案
使用 Excel.Workbook
,然后你可以使用 Workbook.Sheets .Count之间的()
在为
或,而
循环。
Use Excel.Workbook
and then you can use the Workbook.Sheets.Count()
in a for
or while
loop.
这篇关于我怎么能确定有多少工作表中有一个Excel工作簿?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文