public static string[] GetConnectionExcel(HttpPostedFile HttpFileUpload,HttpServerUtility ServerHU)
{
string[] strExcelConn = new string[2];
string strFileName = ServerHU.HtmlEncode(HttpFileUpload.FileName);
string strExtension = Path.GetExtension(strFileName);
if (strExtension != ".xls" && strExtension != ".xlsx")
{
return strExcelConn;
}
string strUploadFileName = "~/UploadFiles/" + DateTime.Now.ToString("yyyyMMddHHmmss") + strExtension;
strExcelConn[1] = strUploadFileName;
HttpFileUpload.SaveAs(ServerHU.MapPath(strUploadFileName));
//if (strExtension == ".xls")
// strExcelConn[0] = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ServerHU.MapPath(strUploadFileName) + ";Extended Properties='Excel 8.0;HDR=YES;'";
//else
strExcelConn[0] = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ServerHU.MapPath(strUploadFileName) + ";Extended Properties='Excel 12.0 Xml;HDR=YES;'";
return strExcelConn;
}