Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding new line in excel cell generated via html

I'm trying to generate an excel file using html in php and responding with an excel Content-type. Everything works fine except new lines within a cell . They are not preserved. I've tried &#13 ;&#10 ; \r\n ,chr(13).chr(10) and it didn't work. I'm trying to get the same result from alt + enter from microsoft Excel .

I am generating in a cell content like:

 http:\\www.example.com\blah
 (Link)
 http:\\www.example.com\blah2
 (Event) ...

these have to be in a single cell and also converting the link text to hyperlinks would be great :).

like image 527
Ovidiu Buligan Avatar asked Oct 26 '10 16:10

Ovidiu Buligan


1 Answers

I've found a solution here: http://www.bennadel.com/blog/1095-maintaining-line-breaks-in-an-html-excel-file.htm

The solution I found is to add into a stylesheet:

br {mso-data-placement:same-cell;}
like image 159
Ovidiu Buligan Avatar answered Nov 15 '22 14:11

Ovidiu Buligan