How can I do a line break in cell of excel using PHP?

excel, php

Solution

After searching a lot found this site: http://www.bennadel.com/blog/1095-maintaining-line-breaks-in-an-html-excel-file.htm

And this tag solves the issue `<br style="mso-data-placement:same-cell;" />`

Thanks for all your comments!!

Problem

Hi I have thw following code: ``` header('Content-type: application/vnd.ms-excel'); header("Content-Disposition: attachment; filename=archivo.xls"); header("Pragma: no-cache"); header("Expires: 0"); echo " <html> <head> <meta charset="utf-8"> <meta http-equiv="expires" content="0"> </head> <body> <table width="100%" border="1" align="center" cellpadding="3" cellspacing="0"> <tr> <td>Line 1<br>Line 2</td> </tr> </table> </body> </html>"; ``` I have tried: ``` <td>Line 1\r\nLine 2</td> <td>Line 1".chr(10) . chr(13)."Line 2</td> ``` But nothing seems to work, I need to do a line break in a cell, any suggestions are welcomed. I'm using excel 2010. I already look at this question: line break within data for Excel 2003 and it didnt work. It doesnt show error, when I apply `<br>` it creates a new row, when I use `\r\n, \n, or chr(10) . chr(13)`, it creates a space. Thanks!!

Original source