作者nbaby19 (sh~~)
看板PHP
标题[请益] 资料表里的资料写入excel
时间Mon Sep 3 19:44:51 2007
要把资料表3个栏位(department,education,class)的所有值写到excel里
我要让excel里的资料看起来是
| number
3个栏位的值 |
3个栏位... |
3个栏位... |
|
以下是当中一段程式
因为写入excel的方法我第一次用
所以不对的地方请指正
还有就是..excel档开起来
$row["department"] $row["education"] $row["class"] 是乱码且只显示一列@@
//------------------------------------
$sql = "SELECT * FROM xxx ";
$result = mysql_query($sql, $link);
$row = mysql_fetch_array($result);
$string="\tnumber";
for( $i=1;$i<=mysql_num_rows($result);$i++ )
{$stringg="\n ".$row["department"]." ".$row["education"]."
".$row["class"]." \n ";
$row = mysql_fetch_array($result);
}
$fp = fopen("texcel.xls", "w");
fputs($fp,$string.$stringg);
fclose($fp);
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.64.183.208
1F:推 alpe:写成csv吧 09/03 21:47