用户
 找回密码
 入住 CI 中国社区
搜索
查看: 4586|回复: 4
收起左侧

[控制器] CI怎么调用PHPEXCEL?

[复制链接]
发表于 2010-10-13 22:31:26 | 显示全部楼层 |阅读模式
有人在CI调用phpexcel成功过吗
以下方法不成功phpexcel
In order to get PHPExcel http://www.codeplex.com/PHPExcel working with CodeIgniter, there are a few steps you must take to ensure compatibility with CodeIgniter’s naming standards.
1: Class names must match the file names. PHPExcel has a few files(such as PHPExcel/IOFactory.php) that have names like PHPExcel_IOFactory. Change these names by removing the “PHPExcel_” part. These constructors in these files must be public in order for CI to access them.
2. To load a library like the IOFactory, simply say:
$this->load->library(‘PHPExcel/iofactory’);

An simple use case of PHPExcel would look like:
$this->load->library(‘phpexcel’);
$this->load->library(‘PHPExcel/iofactory’);
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setTitle(“title”)
            ->setDescription(“description”);
               
// Assign cell values
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue(‘A1’, ‘cell value here’);
// Save it as an excel 2003 file
$objWriter = IOFactory::createWriter($objPHPExcel, ‘Excel5’);
$objWriter->save(“nameoffile.xls”);
发表于 2010-10-14 15:11:53 | 显示全部楼层
外面架设一个专用的吧。以后都用它来导入到MYSQL。
发表于 2010-10-14 15:36:06 | 显示全部楼层
我们首选的都是phpexcel这套类。它拥有强大的PHP和EXCEL互转功能。
实例代码在这个地址
http://phpexcel.codeplex.com/
 楼主| 发表于 2010-10-19 21:51:45 | 显示全部楼层
哥们我调用成功了 原来是php版本太低,phpexcel1.7.4需要php5.2以上版本
发表于 2011-6-3 10:52:37 | 显示全部楼层
这个不错。

本版积分规则