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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
orangeapple
Forum Commoner
Posts: 70
Joined: Tue Jan 06, 2004 1:24 pm
Location: Geneva / Switzerland

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

Post 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 !
Last edited by orangeapple on Sun Oct 09, 2005 4:00 pm, edited 1 time in total.
Black Unicorn
Forum Commoner
Posts: 48
Joined: Mon Jun 16, 2003 9:19 am
Location: United Kingdom

Post 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
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

User avatar
orangeapple
Forum Commoner
Posts: 70
Joined: Tue Jan 06, 2004 1:24 pm
Location: Geneva / Switzerland

Post 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 !!!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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. :)
User avatar
orangeapple
Forum Commoner
Posts: 70
Joined: Tue Jan 06, 2004 1:24 pm
Location: Geneva / Switzerland

Post 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 !!
User avatar
orangeapple
Forum Commoner
Posts: 70
Joined: Tue Jan 06, 2004 1:24 pm
Location: Geneva / Switzerland

Post by orangeapple »

anyone ?
Post Reply