Web Hosting Talk







View Full Version : Inserting a carriage return into an Excel document, via PHP


BurakUeda
07-20-2008, 09:18 AM
Trying to create an .xls document on the fly, using PEAR Spreadsheet_Excel_Writer (http://pear.php.net/package/Spreadsheet_Excel_Writer/docs). Everything seems fine so far, except I cannot insert a carriage return into a cell.
\l, \l\r, chr(13) none is working.
I am not an Excel user, so anyone has any idea how can I accomplish this?

Eanix
07-20-2008, 09:47 AM
Have you tried \r\n ?

BurakUeda
07-20-2008, 10:49 AM
Thanks Eanix,
It works in a weird way.
Entering the data in each cell like this:
Number:0\r\nnextline
Number:1\r\nnextline
Number:2\r\nnextline
Number:3\r\nnextline

When I run the script and view the file in Excel, it looks like:

Number:0nextline
Number:1nextline
Number:2nextline
Number:3nextline

But after I double click each cell, it gets formatted automatically:
Number:0
nextline

Number:1
nextline

Number:2
nextline

Number:3
nextline

BurakUeda
07-20-2008, 11:04 AM
Fixed :D
I needed to use setTextWrap() function...