问题
Contrary to what I would think, multiple selected sheets are not a Worksheets object type.
After multi-selecting 2 or more sheets. The way I get the selection is as so:
var selection = ExcelApp.Selection; //Returns object type
I've tried getting the "Name" property to try and give me a hint by using late binding with:
string name = selection.GetType().InvokeMember("Name", System.Reflection.BindingFlags.GetProperty, null, selection, null).ToString();
But this throws errors for the given selection type.
Any ideas?
回答1:
In VBA, ActiveWindow.SelectedSheets
returns a Sheets
collection, so I imagine it will be similar in C#
Yep: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.window.selectedsheets(v=office.11).aspx
来源:https://stackoverflow.com/questions/10591443/what-object-type-are-multiple-selected-sheets-in-excel