我用 C# 编写了代码,然后使用在线转换器工具将其转换为 VB
C#代码:-
ExcelObj = new ExcelShet.Application();
ExcelShet.Workbook theWorkbook = ExcelObj.Workbooks.Open(filepath);
ExcelShet.Sheets sheets = theWorkbook.Worksheets;
ExcelShet.Worksheet worksheet = (ExcelShet.Worksheet)sheets.get_Item(1);
转换后的 VB 代码
Dim ExcelObj As New ExcelShet.Application()
Dim theWorkbook As ExcelShet.Workbook = ExcelObj.Workbooks.Open(filepath)
Dim sheets As ExcelShet.Sheets = theWorkbook.Worksheets
Dim worksheet As ExcelShet.Worksheet = DirectCast(sheets.get_Item(1), ExcelShet.Worksheet)
现在的问题是-VB 没有函数 get_item(object index)
Dim worksheet As ExcelShet.Worksheet = DirectCast(sheets.get_Item(1), ExcelShet.Worksheet)
有谁知道如何像我在 C# 中那样选择工作表,或者我应该使用哪种方法而不是 get_item(object index)