Created
July 1, 2013 09:55
-
-
Save cwschroeder/5899664 to your computer and use it in GitHub Desktop.
Read Excel file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void Read() | |
{ | |
var fileName = string.Format(@"c:\temp\test.xlsx"); | |
var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", fileName); | |
var adapter = new OleDbDataAdapter("SELECT * FROM [Tabelle1$]", connectionString); | |
var ds = new DataSet(); | |
adapter.Fill(ds, "myDs"); | |
var data = ds.Tables["myDs"].AsEnumerable(); | |
foreach (var row in data) | |
{ | |
Console.WriteLine(string.Format("1: {0}, 2: {1}.", row[0], row[1])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment