Page 1 of 1

how to change line in a xls generated file ? (NOT SOLVED)

Posted: Wed Sep 28, 2005 7:12 am
by orangeapple
Hi,

I am trying to generate a file from a database extract that I would like to be open in excel.
I found out how to change from cell to cell in excel to separate the datae but not how to change from line to the line below.

Does someone know how to separate the datae in order to change the line in excel ?

Thanks a lot !

Posted: Thu Sep 29, 2005 4:10 am
by Black Unicorn
If you're using plain CSV (comma separated values) the next line is marked by a newline \n.
Since it's M$, best bet would be to add a return carriage as well, i.e. \r\n

For example,
$csv = "col1A,col2A,col3A,col4A\r\ncol1B,col2B,col3B,col4B"

Hope it works.
H

Posted: Thu Sep 29, 2005 5:48 am
by Jenk

Posted: Thu Oct 06, 2005 2:14 pm
by orangeapple
i can't figure out the right synthax.

this :

Code: Select all

$table = fgetcsv($id, $msg_from, $msg_date, $msg_gmt, $alarm_mac_id, $alarm_date, $level, $name, $value, $description, $alarm_value, $alarm_ack) ;

echo $table;
is obviously wrong, doesn't work. this is the error message :

<b>Warning</b>: Wrong parameter count for fgetcsv() in <b>c:\program files\easyphp1-8\www\microsent\pages\dataexport_answer.php</b> on line <b>93</b><br />
<br />

can someone help me ?

thanks a lot !!!

Posted: Thu Oct 06, 2005 5:28 pm
by feyd
didn't really read the documentation page eh? :P
array fgetcsv ( resource handle [, int length [, string delimiter [, string enclosure]]] )
There are 4 possible arguments to the function. The first is required: the resource handle (created by fopen() for example.) The rest are optional. For more information read the documentation link posted by Jenk. :)

Posted: Sat Oct 08, 2005 11:42 am
by orangeapple
well... :? I did actually read the documentation, but since I'm very far to be an expert in php, I'm not sure to understand it well...

All I want to do is that these different variables appear in a different cell but on the same line in excel and that a return carriage is done at the end of the line :

Code: Select all

$id, $msg_from, $msg_date, $msg_gmt, $alarm_mac_id, $alarm_date, $level, $name, $value, $description, $alarm_value, $alarm_ack
Does it mean that i have to create a .txt file with the database content and then open it and format it with fgetcsv() ?

Thanks for your help !!

Posted: Sun Oct 09, 2005 4:01 pm
by orangeapple
anyone ?