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; }
public override string HtmlEncode(string s) { return(w.HtmlEncode(s)); }
/// <summary> /// See <see cref="HttpServerUtility"/> for a description. /// </summary> public string HtmlEncode(string s) { return(_httpServerUtility.HtmlEncode(s)); }
public static string ConvertNormalTextToHTMLFormat(System.Web.HttpServerUtility serverObj, string orgText) { return("<p>" + serverObj.HtmlEncode(orgText).Replace("\n", "</p><p>").Replace("\r", "") + "</p>"); }