Page 2 of 2

Posted: Thu Dec 14, 2006 1:00 am
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

Posted: Thu Dec 14, 2006 3:15 am
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

Posted: Thu Dec 14, 2006 3:46 am
by madhu
Hi i got the solution by keeping \t after every field name