作者cleanwind (骨傲风清(挂网))
看板PHP
标题Re: [请益] 资料表里的资料写入excel
时间Tue Sep 4 00:16:34 2007
Excel 档案栏位分隔是用 \t
分行则是用 \r
至於 \n 我就不清楚有啥用途了 :p
※ 引述《nbaby19 (sh~~)》之铭言:
: 要把资料表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: 59.117.204.78
1F:推 alpe:在win下分行应该是 /r/n 09/04 09:06
2F:推 cleanwind:excel内的分行, \r 就可以了... 09/04 09:36