public void ReadExcel(HttpPostedFileBase file, string currentUserName)
{
DataTable tbContainer = new DataTable();
string strConn = XlsConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + file.FileName +";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'";
string sheetName = "sheet1";
FileInfo fileInfo = new FileInfo(file.FileName);
OleDbConnection cnnxls = new OleDbConnection(strConn);
OleDbDataAdapter oda = new OleDbDataAdapter(string.Format("select * from [{0}$]", sheetName), cnnxls);
DataSet ds = new DataSet();
oda.Fill(tbContainer);
var newParcelTubeExport = new ParcelTubeExport();
//your code to utilize the data
}
No comments:
Post a Comment