Posted on: 7/27/2015 7:38:44 PM | Views : 708

DataTable dtExcel = RequestHelper.ImportExcelToDataTable(postModel.Attachment.FileName).Tables[0]; string fileExtension = Path.GetExtension(fileName); if (fileExtension == ".xlsx") { m_connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=\"Excel 12.0;IMEX=1;HDR=YES;TypeGuessRows=0;ImportMixedTypes=Text\""; } using (var conn = new OleDbConnection(m_connectionString)) { conn.Open(); var sheets = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" }); using (var cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT * FROM [" + sheets.Rows[0]["TABLE_NAME"].ToString() + "] "; ...

Go to the complete details ...