[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

ADO.Net - Excel - 1st Worksheet

Posted on 2009-06-29
3
Medium Priority
?
394 Views
Last Modified: 2013-12-17
I use ADO.Net to open an Excel workbook.

If I know the name of the first worksheet, I can get the data no problem.

Is there a way to reference the first worksheet whatever its name is when creating the Command object?
0
Comment
Question by:Éric Moreau
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 1600 total points
ID: 24735808
C# - Retrieve Excel Workbook Sheet Names.
http://www.codeproject.com/KB/aspnet/getsheetnames.aspx
0
 
LVL 15

Assisted Solution

by:mohan_sekar
mohan_sekar earned 400 total points
ID: 24735813
0
 
LVL 70

Author Comment

by:Éric Moreau
ID: 24735913
Excellent.

The answer is: cn.GetOleDbSchemaTable(OleDb.OleDbSchemaGuid.Tables, Nothing)
or: cn.GetSchema("Tables")

which both return a datatable.

The only problem with this is that you have no clue which sheet is the first one (as they seem to be sorted by name).

It is not really a problem for me as the workbook contains a single worksheet (but my tests showed me multiple worksheets).
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question