The Following C# code is used to Export data from ASP.NET to Excel with special characters try { Response.ContentType = "application/vnd.ms-excel 8.0"; Response.Charset = ""; Response.ContentEncoding = System.Text.Encoding.Default; this.EnableViewState = false; System.IO.StringWriter ObjWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter ObjHtmlTextWriter = new System.Web.UI.HtmlTextWriter(ObjWriter); rptUserDetails.RenderControl(ObjHtmlTextWriter); //dgdInitiative is the Grid name which is to be exported Response.Write(ObjWriter.ToString()); string strhtml = ObjHtmlTextWriter.ToString(); Response.AppendHeader("content-disposition", "attachment;filename=Users.xls"); Response.End(); } catch (System.Exception ex) { string strMsg = ex.Message; }
The Following Function will help to get plain text from the FCKEditor in almost any browser. // below is the protyping for trim string. function trimString (str) { str = this != window? this : str; return str.replace(/^\s+/g, '').replace(/\s+$/g, ''); } String.prototype.trim = trimString; //following function will return plain text function GetPlainText(FCKEditorID) { var FEditor = FCKeditorAPI.GetInstance(FCKEditorID); var Result = ""; if (FEditor.EditorDocument.body.textContent || FEditor.EditorDocument.body.textContent=="" ) { //Firefox compitable browser Result = FEditor.EditorDocument.body.textContent.trim(); } else { //IE compitable browser Result = FEditor.EditorDocument.body.innerText.trim(); } return Result; }
Comments