Ronald
Ronald

Reputation: 51

How to select separate columns in Excel

I have searched a lot but didn't find a question like what I have.

I am opening an excel sheet with an OleDB connection and want to select (unnamed) columns, but not an entire range. The columns I want to select are:

B, F, M, O-X

I have tried a lot of ways to format the select and the closest I come to a result that actually passes through is this:

"SELECT TOP " + this.maximumRows.ToString() + " * FROM [Sheet1$B:B], [Sheet1$F:F], [Sheet1$M:M], [Sheet1$O:X]"

However what i get out of that is this (commas separate cells):

Data , [Sheet1$F:F] , [Sheet1$M:M] , [Sheet1$O:X] , F2 , F3 , etc...

Can anyone tell me how to form the SELECT statement so it takes the actual data instead of the rest of the query?

Upvotes: 0

Views: 3626

Answers (1)

iDevlop
iDevlop

Reputation: 25262

I would rather try something like SELECT TOP X F2, F6 from [Sheet1] ?

Upvotes: 1

Related Questions