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?
Who is Participating?
Miguel OzConnect With a Mentor Software 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)

Open in new window

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?
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
rwheeler23Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.