如何在 laravel 中安装 PHPExcel 库?
我正在尝试使用这个库来创建 excel 文件,但不是如何安装它.我正在考虑从其主页下载该库 (http://phpexcel.codeplex.com/wikipage?title=Examples) 但也不知道应该放在哪个文件夹.如何安装?
I'm trying to use this library to create excel files but not how to install it. I was considering to download the library from its home page (http://phpexcel.codeplex.com/wikipage?title=Examples) but also do not know what folder should I place it. How I can install?
推荐答案
你应该使用 composer: 将 "phpexcel/phpexcel": "dev-master"
添加到你的composer.json
"require": {
"phpexcel/phpexcel": "dev-master"
}
然后执行composer update
.所以你可以正常使用它:
Then execute composer update
. So you can use it as normal:
public function import($path){
$objPHPExcel = PHPExcel_IOFactory::load($path);
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestRow = $objWorksheet->getHighestRow();
for ($row = 1; $row <= $highestRow; ++$row) {
var_dump($objWorksheet->getCellByColumnAndRow(1, $row));
}
}
相关文章