0

Is there a way retrieving Data from an Excel-Sheet using ADO.net and header names when the headers are not on row one?

e.g.

[1: |BLANK | BLANK | BLANK   | ] < Blank row
[2: |Name  | Age   | Address | ] < Header row
[3: |John  | Smith | Abstr.  | ] < Data row

Isn't there a possibility to specify a "starting cell" ? e.g.

Range A9:EndOfFile

And would this trick resolve my problem?

2
  • Could you not pull the data as a recordset and query it with a SELECT statement where the record is not null? Admittedly my understanding of ADO is VERY basic, but I'm sure it's designed to be used with actuall data tables, which shouldn't have any blank rows. Can you not change the layout of the workbook? Commented Dec 2, 2014 at 14:34
  • ty for the comment - no, unfortunately I can not change the layout. Blank rows were just for explaining my problem, the original file I want to retrieve got some text above the actual data ( e.g. descriptions in connected cells) Commented Dec 2, 2014 at 14:40

1 Answer 1

1

Perhaps you could import the dataset from Excel as if it did not have a header row, then extract the data from the desired row and use programmatically set the headers for your DataTable from that data. For the ConnectionString, you can set HDR=NO to read every row as data.

Here's a link related to Excel ConnectionStrings and the HDR setting: https://www.connectionstrings.com/excel/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.