Hello
I am using c# to run a SQL Server 2005 stored procedure results into a data table and exporting the data table to either Excel or Word
However one of the column names the stored procedure returns a £ sign and when this is exported into either word or excel is displays £.Code:string filter = ""; string strProcedure = ""; if (_listProfile.ApplyFilter) filter = _listProfile.Filter; if (_listProfile.ExportStoredProcedure == "" | _listProfile.ExportStoredProcedure == null) strProcedure = _listProfile.SourceStoredProcedure; else strProcedure = _listProfile.ExportStoredProcedure; DataTable dataTable = UtilityFunctions.ExecuteCollectionFetchStoredProcedure(Application["ConnectionString"].ToString(), strProcedure, _listProfile.ParentID, _listProfile.ParentColumnName, filter, _listProfile.Sort); StringBuilder content; string contentType = ""; //Get content... if (exportTo.ToUpper().Equals("WORD")) { content = GetWordContent(dataTable); contentType = "application/vnd.ms-word"; } else { content = GetExcelContent(dataTable); contentType = "application/vnd.ms-excel"; } //Assemble content in literal control... StringWriter stringWriter = new StringWriter(); HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter); Literal literal = new Literal(); literal.Text = content.ToString(); literal.RenderControl(htmlTextWriter); //Deliver content... Response.Clear(); if (exportTo.ToUpper().Equals("WORD")) Response.AddHeader("content-disposition", "attachment;filename=Document1.doc"); if (exportTo.ToUpper().Equals("EXCEL")) Response.AddHeader("content-disposition", "attachment;filename=Document1.xls"); Response.ContentType = contentType; Response.Write(stringWriter.ToString()); Response.Flush(); Response.End();
Can anyone help?
Thanks
Kev




Reply With Quote