I'm using NetAdvantage 10.1. In an UltraGrid I have one cell that contains multiple items formatted to appear on multiple lines within the cell. The content looks like this
Item 1<br />Item 2<br />Item 3<br />
That works great and appears like it should on the screen.
Since Excel doesn't recognize the HTML <br />, I use the CellExporting event to replace it with CR/LF. Unfortunately, this doesn't work. I've tried multiple variations (just CR, just LF) with no luck. Somewhere in the process the CR/LF gets replaced with a single space character so the exported cell contents end up like this
Item1 Item 2 Item 3
Does anyone know a workaround for this?
Hello Rob,
I was able to resolve the issue with the suggestion.
Can you please provide us with an isolated sample reproducing the issue?
Hope hearing from you.
The issue is still unresolved. See my previous posting in response to the first suggestion.
Hi,
Do you still need assistance with this issue?
Do not hesitate to contact us if you have any further questions.
Regards,
Lyuba
Developer Support Engineer
Infragistics
www.infragistics.com/support
I had all of the elements you describe in place except using "Environment.NewLine" as the replacement for "<br />". Changing to "Environment.NewLine" gave exactly the same result as using vbCrLF, vbCr, or VbLf as the replacement. Which is to say, the exported cell ends up with the items in the list separated by a single space (I can see this visually, but to verify it I copy the contents of the Excel cell into a hex editor to examine it and make sure what I'm seeing is hex 20).
You can replace the <br/> tag with new line (\n) inside the CellExporting event
using the following code snippet:
if (collumnIndex == 1)
{
if (e.GridRow != null)// null if the cell is in the header
e.Value = e.Value.ToString().Replace("<br/>", Environment.NewLine);
}
Inside the CellExported you have to set the format of the cell's collumn and row, for example :
protected void UltraWebGridExcelExporter1_CellExported(object sender, Infragistics.WebUI.UltraWebGrid.ExcelExport.CellExportedEventArgs e)
int collumnIndex = e.GridColumn.Index;
e.CurrentWorksheet.Columns[e.CurrentColumnIndex].Width = 2000;
e.CurrentWorksheet.Columns[e.CurrentColumnIndex].CellFormat.WrapText = ExcelDefaultableBoolean.True;
if (e.GridRow != null) // null if the cell is in the header
int rowIndex = e.GridRow.Index;
e.CurrentWorksheet.Rows[rowIndex].Height = -1;
Please let me know if you need further assistance regarding this.