Reputation: 1837
I am trying to get names of the selected sheets in Excel. I have 4-5 worksheets in my excel file. User is supposed to select two of them and then my application scans specific columns and compare values. However I could not find a way in C# to get names of the worksheets when user selects more than one sheet. User can also delete these selected worksheets via the application. Any ideas?
Upvotes: 3
Views: 900
Reputation: 1177
Using VSTO:
var sheets = Application.ActiveWindow.SelectedSheets;
var names = new List<string>();
foreach (Excel.Worksheet sh in sheets)
{
names.Add(sh.Name);
}
Upvotes: 2
Reputation: 4009
If you're after a free solution, have a look at Excel Package Plus: http://epplus.codeplex.com/
It should have all the features that you require.
Upvotes: 0
Reputation: 121
One way is to use Spreadsheetgear: Link to Spreadsheetgear website
This is the easiest solution to manipulating Excel workbooks I tryed. But quite expensive.
Upvotes: 1