Hi,
I cannot seem to figure out why carriage returns are not being displayed in the excel documents being produced by using the .ExportToExcel() call.
My .aspx file includes the following:
<form id="form1" runat="server"> |
<asp:ScriptManager ID="ScriptManager1" runat="server" /> |
<telerik:RadGrid ID="radGrid" runat="server"></telerik:RadGrid> |
</form> |
My code behind pulls data from my database and then does the following:
radGrid.DataSource = ds; |
radGrid.DataBind(); |
radGrid.ExportSettings.ExportOnlyData = true; |
radGrid.ExportSettings.IgnorePaging = true; |
radGrid.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.ExcelML; |
radGrid.ExportSettings.FileName = "excel_export.xls"; |
radGrid.MasterTableView.ExportToExcel(); |
When I query the database I loop through the record set to manipulate the data. For example, I use System.Web.HttpUtility.HtmlDecode("string here") to render html encoding properly and if I add .Replace("\n","[line break here]") I see the bracketed text in the resulting excel document.
But I can't get an actual line break to appear! I've tried replacing both "\r", "\n", and "\r\n" with Convert.ToChar(10).ToString(), Convert.ToChar(13).ToString(), and Convert.ToChar(10).ToString() + Convert.ToChar(13).ToString() --- nothing works.
If I use .Replace("\n","<br />") and change the export format to Telerik.Web.UI.GridExcelExportFormat.Html I see the line breaks, but new rows are created is Excel - which renders common excel functionality like sorting and filtering useless.
Help!