如何在 laravel 中安装 PHPExcel 库? [英] How I can install the PHPExcel library in laravel?

查看:36
本文介绍了如何在 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));
    }

}

这篇关于如何在 laravel 中安装 PHPExcel 库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆