PHPExcel integration into Zend Framework(PHPExcel 集成到 Zend 框架中)
问题描述
如何将 PHPExcel 集成到我的 Zend 应用程序中.
how can I integrate the PHPExcel into my Zend app.
我的实际文件夹结构如下:
My actual folder structure is the following:
/application
controllers
views
etc...
/library
My
Zend
PHPExcel
/public
index.php
我已经通过使用(在 index.php 中)包含了我的"库:
I already include 'My' libs by using (in index.php):
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('My_');
现在我还想在我的一个控制器中使用 PHPExcel,例如:
Now I also want to use PHPExcel inside one of my controllers like:
$exc = PHPExcel_IOFactory::load('test.xls');
$excelWorksheet = $exc->getActiveSheet();
我该怎么做才能使它工作并摆脱 Class 'PHPExcel_IOFactory' not found 异常?
What do I have to do to make it work and get rid of the Class 'PHPExcel_IOFactory' not found Exception?
谢谢.
-lony
Thank you.
-lony
PS:一个简单的 $autoloader->registerNamespace('PHPExcel_'); 不起作用.我测试过了.
P.S.: A simple $autoloader->registerNamespace('PHPExcel_'); is not working. I tested it.
推荐答案
将PHPExcel库放入/library文件夹,如下:
Place the PHPExcel library into the /library folder, like this:
/application
...
/library
/PHPExcel
/PHPExcel.php
接下来,在您的 application.ini 配置文件中,添加以下内容:
Next, in your application.ini config file, add the following:
autoloaderNamespaces[] = "PHPExcel_"
autoloaderNamespaces[] = "PHPExcel"
应该可以.Autoloader 负责其余的工作,您只需开始使用示例代码读取 Excel 文件即可.
That should do it. Autoloader takes care of the rest, and you can just start using the example code to read an Excel file.
更新:添加了评论者建议的额外 autoloaderNamespace
Update: Added the extra autoloaderNamespace as suggested by commenters
这篇关于PHPExcel 集成到 Zend 框架中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHPExcel 集成到 Zend 框架中
基础教程推荐
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何替换eregi() 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
