1

Possible Duplicate:
Reading Excel files from C#

I have seen similar post, but mine is more trivial than the others I have seen.

I need to do read the default worksheet from an excel file, and get the first 3 columns of data and import them into my app as in a List

List<MyObj> obj = new List<MyObj>();.

 obj.col1 = ...
 obj.col2 = ...
 obj.col3 = ...

There are no headings in the document just data. Also would be good to have a solution that works for both formats (XLS,XLSX) but if not possible than thats ok.

Also is it different code for XLSX and XLS ?

Im using .NET 2 but if need I could use c# 4

col1data  |  col2data | col3data
col1data  |  col2data | col3data
col1data  |  col2data | col3data
col1data  |  col2data | col3data
...
Community
  • 1
  • 1
IEnumerable
  • 3,610
  • 14
  • 49
  • 78
  • See http://stackoverflow.com/questions/15828/reading-excel-files-from-c-sharp – Mike Park Oct 12 '12 at 19:29
  • thanks it looks ok, but Im not sure what do I put in place of ..adapter.Fill(ds, "anyNameHere"); – IEnumerable Oct 12 '12 at 19:46
  • adapter is going to be an instance of the DataAdapter class. It is what is used to represent the data-source in memory for the purpose of reading/writing. Basically in that example the data adapter is used to fill a DataSet object with the data from the Excel document. – Mike Dinescu Oct 12 '12 at 19:47
  • ok thanks, I think I have it. – IEnumerable Oct 12 '12 at 19:52

0 Answers0