Re: [請益]請問php怎樣讀excel檔案內的欄位

看板PHP作者 (熱情的獨居老人..)時間19年前 (2006/03/09 17:47), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串4/4 (看更多)
※ 引述《swinds24 (囧興( ̄⊿ ̄|||))》之銘言: : ※ 引述《oiolong (熱情的獨居老人..)》之銘言: : : $fp = fopen("store.csv", "r"); : : $i = 0; : : while (!feof($fp)) { : : $ar[$i] = fgetcsv($fp, 1024,","); : : //利用 fgetcsv來取得單行資料 : : $i++; : : } : : fclose($fp); : : 再來就看你如何應用了.... : : 以上 : 那另外想到一個反向的問題 : 如果是php+mysql的組合 : 想要再將資料儲存到excel檔案中 : 這樣的情況該如何去實作?? : 自己只有想到用"人工的"方法去一個一個填( ̄□ ̄|||)a : 先謝謝各位前輩了 基本上adodb有這個小功能 首先先 include toexport.inc.php 一般來說就在adodb裡的資料夾內 再來就簡單啦 $conn = &ADONewConnection('mysql'); $conn->Connect('localhost','帳號',密碼','資料庫'); $sqlx = "select orders_id as '訂單編號',products_id as '卡別', customers_channel as '店家代號', customers_company as '店家名稱' , customers_address as '店家地址' , customers_telephone as '店家電話' from orders where orders_id = $ordersId"; //將原本的欄位的標頭取代成中文 $rss=& $conn->Execute($sqlx); $fhd = fopen("檔案名稱", "w"); rs2csvfile($rss, $fhd); fclose($fhd); -- http://www.wretch.cc/blog/oiolong 我的網誌~ 歐爺~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.229.0.79

03/09 23:19, , 1F
感謝<(__ __)>不過真的有點難懂XDD還是要好好研究研究
03/09 23:19, 1F
文章代碼(AID): #143_d3y9 (PHP)
文章代碼(AID): #143_d3y9 (PHP)