Last active
December 14, 2015 23:19
-
-
Save jbubriski/5164856 to your computer and use it in GitHub Desktop.
Reading an excel using the Microsoft.ACE.OLEDB driver.
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
var fileName = "file.xlsx"; | |
var connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", fileName); | |
var query = "select * from [{0}$]"; | |
using (var dataAdapter = new OleDbDataAdapter(string.Format(query, "worksheet name"), connectionString)) | |
{ | |
var dataSet = new DataSet(); | |
dataAdapter.Fill(dataSet); | |
var myTable = dataSet.Tables[0]; | |
foreach (DataRow dataRow in myTable.Rows) | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment