1

I chose OleDb as a method of reading data from Excel, one of my problems on parsing the Excel is this:

I want to skip a few rows from the file (let's call them a header..) - there are merged cells there and other stuff I need to ignore, I found this syntax:

'SELECT * FROM [Sheet1$a4:c]',

specifying "a4" - the left corner of the header row, and "c" - the right most column where the data is ..how ever this is not OK to me as I do not know the exact number of columns with data I need to parse ...Is there another way of accomplishing this ?

3
  • 1
    Any reason why you cannot use a little code to find the bottom right cell? Commented Dec 18, 2011 at 22:15
  • Well...no particular reason, I checked & it works, it seems that I just read somewhere that Ole would take the first row to calculate the columns number, which seems to be incorrect .... Commented Dec 19, 2011 at 8:50
  • 'SELECT * FROM [Sheet1$A4:end]' Commented Sep 1, 2022 at 6:12

1 Answer 1

4

you can take all rows in a dataTable and then

IEnumerable<DataRow> newRows = dt.AsEnumerable().Skip(1);
DataTable  dt2 = newRows.CopyToDataTable();

dt2 now contains all rows but the first.

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.