Hi,
I am using VS 2012, C# and ASP.NET
I am reading the contents of excel document and adding to a datatable using the oledb connection.
Below is the code used:
string[] workSheetNames = new string[] { }; //List of Worksheet names
System.Data.DataTable dtExcelData = new System.Data.DataTable();
string SourceConstr = string.Empty;
if (strExtension == ".xls")
{
SourceConstr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + ExcelPath + "';Extended Properties= 'Excel 8.0;HDR=Yes;IMEX=1'";
}
if (strExtension == ".xlsx")
{
SourceConstr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + ExcelPath + "';Extended Properties= 'Excel 12.0;HDR=Yes;IMEX=1'";
}
using (OleDbConnection ...
Go to the complete details ...