Server to server file transfer using php

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

madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

Post by madhu »

Hi all,

Am facing a small problem, please help me.

Before i wrote the content in .csv format with the delimiter ','

Now am trying to write the content in .xls format . when i tried to write to xls file, the content is coming in the single line.

Can any one help me how to put delimiter for xls file.

Code: Select all

include("inc.php");
$db = mysql_connect($my_server,$my_user,$my_pass) or die("Unable to connect to MySQL");
mysql_select_db($data_base) or die("failed opening database");
$result = mysql_query("select * from gallery");

$fp = fopen("madhu.xls", "a");
fwrite($fp, "entrydate  albumname\n");

while($row = mysql_fetch_array($result)){
      fwrite($fp, "$row[albumname]  $row[albumname]\n");
     }
fclose($fp);
Waiting for your replies....
Thanks and regards
MADHU
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

By .xls you mean a "standars" microsoft excel file? That file format is described in http://sc.openoffice.org/excelfileformat.pdf and I don't think you really want that. What do you want to achieve?

p.s.: the "solution" might be as easy as replacing \n by \r\n
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

Post by madhu »

Hi i got the solution by keeping \t after every field name
Post Reply