作者nerv3890 (阿渊)
看板PHP
标题[请益] JpGraph读Excel档
时间Sun May 12 20:53:41 2013
如题
我会用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)
1F:→ elba:$ydata=array(); 05/12 21:28
2F:→ 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)
3F:→ nerv3890:已解决~ 05/12 23:30
4F:→ 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)
5F:→ joedenkidd:phpexcel 好像有一个 getarray动作可以把excel ->array 05/13 08:51