Excel中多个选定工作表的对象类型是什么

本文关键字:对象 类型 是什么 工作 Excel | 更新日期: 2023-09-27 18:34:05

与我的想法相反,多个选定的工作表不是工作表对象类型。

多选 2 张或更多张后。我获得选择的方式如下:

var selection = ExcelApp.Selection; //Returns object type

我尝试获取"Name"属性,以尝试通过使用后期绑定来给我一个提示:

string name = selection.GetType().InvokeMember("Name", System.Reflection.BindingFlags.GetProperty, null, selection, null).ToString();

但这会为给定的选择类型抛出错误。

有什么想法吗?

Excel中多个选定工作表的对象类型是什么

在 VBA 中,ActiveWindow.SelectedSheets 返回一个Sheets集合,所以我想它在 C# 中会类似

是的:http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.window.selectedsheets(v=office.11).aspx