Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# export to excel replace <br/> with a line break in a cell

I'm exporting data to excel. Is it possible to replace <br/> in a string with a line break (alt+enter) so that when exported to excel the string is displayed on separate lines in the same cell.

For example:

string text = "Number One" + "`<br/>`" + "Number Two"

Excel:

Number One
Number Two
like image 522
Ros Avatar asked Apr 28 '11 13:04

Ros


Video Answer


1 Answers

Only what you need it's add style="mso-data-placement:same-cell;" inside <br /> tag. Data will be displayed on separate lines but in the same cell.

<br style="mso-data-placement:same-cell;" />
like image 192
isxaker Avatar answered Sep 25 '22 18:09

isxaker