How to display list of tabs in an Excel spreadsheet using C#?

I have a client who sends me spreadsheets full of customer data. Up until now it was always one spreadsheet per customer. Now they are putting each of their  customer's data on a  separate tab inside one spreadsheet. How do I now update my C# code to give them a selection box for each tab and then read the data in the tab chosen?
LVL 1
rwheeler23Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Miguel OzSoftware EngineerCommented:
Use Microsoft.Office.Interop.Excel: (This library depends on which version of Excel you are using)

using Excel = Microsoft.Office.Interop.Excel;

Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@"Book1.xlsx");
foreach (Excel.Worksheet displayWorksheet in xlWorkbook.Worksheets)
{
    Debug.Writeline(displayWorksheet.Name);
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rwheeler23Author Commented:
Thanks. They have a mixture of Excel 2010 and 2013. I will tell them to always use the same one. I suppose a logical follow-up question would be is a way to determine which version they are using?
0
Miguel OzSoftware EngineerCommented:
No the interop works OK with older versions as well, just add the 2013 assembly to your project and you should  be fine
0
rwheeler23Author Commented:
'Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.