[請益] JpGraph讀Excel檔

看板PHP作者 (阿淵)時間11年前 (2013/05/12 20:53), 編輯推噓0(005)
留言5則, 3人參與, 最新討論串1/1
如題 我會用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)

05/12 21:28, , 1F
$ydata=array();
05/12 21:28, 1F

05/12 21:29, , 2F
$ydata[]=你要加入的值;
05/12 21:29, 2F
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)

05/12 23:30, , 3F
已解決~
05/12 23:30, 3F

05/12 23:30, , 4F
謝謝E大!!!
05/12 23:30, 4F
附上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)

05/13 08:51, , 5F
phpexcel 好像有一個 getarray動作可以把excel ->array
05/13 08:51, 5F
文章代碼(AID): #1HZv3NEm (PHP)