maraya/cake-php-excel
Composer 安装命令:
composer require maraya/cake-php-excel
包简介
CakePHP excel generator using PHPExcel library
README 文档
README
A plugin to generate Excel files with CakePHP. Uses CakePHP view files to generate them (with PHPExcel_IOFactory class from PHPExcel).
Requirements
- PHP 5.2.8
- CakePHP 2.1+
- PHPExcel
- Composer
Installation
Add to your composer.json file (maraya/cake-php-excel)
"require": {
"maraya/cake-php-excel": "1.1.*"
},
"config": {
"vendor-dir": "Vendor/"
},
"extra": {
"installer-paths": {
"Plugin/CakePHPExcel": ["maraya/cake-php-excel"]
}
}
And run
composer update
Usage
In app/Config/bootstrap.php add:
CakePlugin::load('CakePHPExcel',
array(
'routes' => true
)
);
Add the RequestHandler component to AppController, and map Excel extensions to the CakePHPExcel plugin
'RequestHandler' => array(
'viewClassMap' => array(
'xls' => 'CakeExcel.Excel',
'xlsx' => 'CakeExcel.Excel'
)
),
Create Layouts/xls/default.ctp (in this example the charset is UTF-8)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php echo $this->fetch('content'); ?>
</body>
</html>
Place the view templates in a xls subdir, for example: app/View/Reports/xls/clients.ctp
<h1>Title</h1>
<table width="100%" border="1">
<tr>
<td>col1</td>
<td>col2</td>
<td>col3</td>
</tr>
<tr>
<td>val1</td>
<td>val2</td>
<td>val3</td>
</tr>
</table>
And in your controller:
class ReportsController extends AppController {
public function clients() {
$this->excelConfig = array(
'filename' => 'clients.xlsx'
);
}
}
Call the URL
http://example.com/reports/clients.xlsx
If you want to download Excel5 format, change the URL extension from xlsx to xls.
Inside your view file you can write HTML code. Please see the PHPExcel documentation for a guide on how to use PHPExcel.
maraya/cake-php-excel 适用场景与选型建议
maraya/cake-php-excel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.42k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2014 年 11 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「excel」 「cakephp」 「PHPExcel」 「maraya」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 maraya/cake-php-excel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 maraya/cake-php-excel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 maraya/cake-php-excel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
CakePHP excel generator
Fork of Maatwebsite for reasons of incompatibility with php >= 7.4 --- of Supercharged Excel exports in Laravel
PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine
Yii2 export extension
统计信息
- 总下载量: 3.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-18