oledb快速导入Excel案例

DataTable dtImportExcel = null;
string pathFile = Server.MapPath("~/ErrorCatory.xlsx");
//string strConn = @"Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + UploadFilePath + ";Extended Properties='Excel 12.0; HDR=Yes; IMEX=1;'";
//strConn = string.Format(strConn, UploadFilePath);
//OleDbConnection connExcel = new OleDbConnection(strConn);
//// where [紧急程度] is not null
//string commandText = string.Format("SELECT * FROM [2013.01$] where [紧急程度] is not null ");
//try
//{
// dtImportExcel = new DataTable("ImportCheck");
// OleDbDataAdapter daImportExcel = new OleDbDataAdapter(commandText, connExcel);
// daImportExcel.Fill(dtImportExcel);
//}
//catch (Exception ex)
//{

//}
//finally
//{

//}

posted @ 2014-03-24 11:41  aiaito  阅读(228)  评论(0编辑  收藏  举报