How to get data of a column of a sheet by c#
-
30-05-2021 - |
Question
I have wrote a winform application that can open and read from a sheet of an excel file.I have used OleDbDataAdapter to read data and then set the data to a datatable. but my problem is that in this datatable the first row of data is used as the name of the columns however i want to use the base names that excel defines for each column (I mean "A B C ... AA AB ..." and so on).
Solution
Take a look at this answer Importing Excel data into C# without first row becoming column names?
It seems you need to change the connection string Extended Properties=\"Excel 8.0;HDR=No;IMEX=1;\"
and make sure HDR=No
is set.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow