How I can install the PHPExcel library in laravel?

前端 未结 5 439
伪装坚强ぢ
伪装坚强ぢ 2020-12-29 08:18

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/w

5条回答
  •  感动是毒
    2020-12-29 09:20

    You should use composer: Add "phpexcel/phpexcel": "dev-master" to your composer.json

    "require": {
        "phpexcel/phpexcel": "dev-master"
    }
    

    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));
        }
    
    }
    

提交回复
热议问题