| View previous topic :: View next topic |
| Author |
Message |
alex
Joined: 13 Sep 2006 Posts: 72
|
Posted: Mon Jul 02, 2007 6:43 pm Post subject: [Solved] Spreadsheet_Excel_Writer - Line break |
|
|
Hi !
I get data grouped "comma separated" from a mysql db. I need to put it in a cell so explode it then implode with a '\n' (with php functions) so that it put text a new line. Here is this code fetching the db results :
| Code: | while($this->fetch()) {
$ex = explode(',', $this->names);
$names = implode('\n',$ex);
$c_data = array( '-',
$names
);
foreach($c_data as $col => $s) {
$c_max_size[$col] = strlen($c_data[$col]);
if($p_max_size[$col]<$c_max_size[$col]) {
$worksheet->setColumn($col,$col,$coeff*$c_max_size[$col]);
$p_max_size[$col]=$c_max_size[$col];
}
$worksheet->write($row, $col, $c_data[$col]);
}
$row++;
} |
So it does not work ... it just prints '\n' and does not write on a new line.
For example :
name1\nname2\nname4
instead I want :
name1
name2
name4
What is the special char to use to break line ?
Thanks.
Last edited by alex on Tue Jul 03, 2007 12:01 pm; edited 1 time in total |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1000
|
Posted: Mon Jul 02, 2007 6:53 pm Post subject: |
|
|
| You might want to have a look into the PHP manual about the difference between '\n' and "\n". |
|
| Back to top |
|
 |
alex
Joined: 13 Sep 2006 Posts: 72
|
Posted: Mon Jul 02, 2007 7:14 pm Post subject: |
|
|
Hi Mark !
Yes , you're right ! I did not see I used simple quotes :\
I then used
nstead of
However, although the "\n" disappears in the result, there is no new line :
name1name2name4
Thanks |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1000
|
|
| Back to top |
|
 |
alex
Joined: 13 Sep 2006 Posts: 72
|
Posted: Tue Jul 03, 2007 12:01 pm Post subject: |
|
|
| Thanks again Mark ! I did not search in the right place in the doc :\ |
|
| Back to top |
|
 |
|