Skip to content

Instantly share code, notes, and snippets.

@nkundu
Created June 5, 2017 18:13
Show Gist options
  • Save nkundu/3c75e60282111acc5e971bbb8a236d32 to your computer and use it in GitHub Desktop.
Save nkundu/3c75e60282111acc5e971bbb8a236d32 to your computer and use it in GitHub Desktop.
Query a Excel File
string connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0; data source={0}; Extended Properties=\"Excel 8.0;IMEX=1\"", fullfilename);
DataSet ds = new DataSet();
using (OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", connectionString))
{
adapter.Fill(ds, "contactRecords");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment