看板 PHP 關於我們 聯絡資訊
如題 我會用JpGraph讀MySQL內的數據 http://nerv3890.blogspot.tw/2013/05/jpgraphmysql.html 也會用PHP讀Excel檔內的數據 http://nerv3890.blogspot.tw/2013/05/phpexcel.html 但要用JpGrapg讀Excel就是不會 QQ 關鍵應該在讀了Excel檔後 $currentSheet = $PHPExcel->getSheet(0); 我不知道怎麼把它裡面的值放入array中... $ydata = $array(" "); 試了幾個寫法都不對 Orz 若我想把Excel中的A行全部拿出來作成一條折線圖 怎麼寫呢? 感恩 QQ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.246.104 ※ 編輯: nerv3890 來自: 140.112.246.104 (05/12 20:54)
elba:$ydata=array(); 05/12 21:28
elba:$ydata[]=你要加入的值; 05/12 21:29
E大我知道是這樣寫~ 但我寫的格式都有問題~ 像這樣 http://nerv3890.blogspot.tw/2013/05/jpgraphexcer.html 感覺問題是出在 for($currentRow = 0;$currentRow < $allRow;$currentRow++){ $ydata[$i]=$array["$col"]; } 這邊compile都會出錯 我不知道怎麼把Excel讀出來的值配到陣列$ydata裡~ ※ 編輯: nerv3890 來自: 140.112.246.104 (05/12 21:44)
nerv3890:已解決~ 05/12 23:30
nerv3890:謝謝E大!!! 05/12 23:30
附上E大的解決方案 $ydata = array(); for($currentRow = 0;$currentRow < $allRow;$currentRow++){ $ydata[] = $currentSheet->getCell("A{$currentRow}")->getValue(); } 不用兩個迴圈,直接把抓到的值加進$ydata裡就好了 ※ 編輯: nerv3890 來自: 140.112.246.104 (05/12 23:31)
joedenkidd:phpexcel 好像有一個 getarray動作可以把excel ->array 05/13 08:51