xianacg/exceler
Composer 安装命令:
composer require xianacg/exceler
包简介
excel表格导入导出工具
README 文档
README
封装 phpspreadsheet 工具类
安装
composer require ogenes/exceler
文档
简单读取
$config['sheet1'] = [ 'goodsName' => '商品名称', 'color' => '颜色', 'price' => '售价', 'actualStock' => '实际库存', ]; $filepath = __DIR__ . '/file/example.xlsx'; return ExcelClient::getInstance()->read($filepath, $config);
DEMO
## 可以再次封装定义企业内的Excel固定模板, class ExcelHelper { public static function export(array $data, array $config, string $filename): string { $client = ExportClient::getInstance(); $fill = [ 'fillType' => Fill::FILL_GRADIENT_LINEAR, 'startColor' => [ 'argb' => 'FFFE00', ], 'endColor' => [ 'argb' => 'FFFE00', ] ]; $client->setStyleHeaderFont([ 'name' => '宋体', 'size' => 11, 'bold' => true, 'color' => ['argb' => '000000'], ]) ->setStyleFont([ 'name' => '宋体', 'size' => 10, 'color' => ['argb' => '000000'], ]) ->setStyleHeaderFill($fill); $client->setFreezeHeader(true); return $client->setFilepath(storage_path('excel') . date('/Y/m/d/')) ->setFilename($filename) ->setData($data) ->setConfig($config) ->export(); } }
## 导出时定义好config即可。 $data['sheet1'] = $list; $config['sheet1'] = [ ['bindKey' => 'orderId', 'columnName' => '订单ID', 'width' => 20, 'align' => Alignment::HORIZONTAL_RIGHT], ['bindKey' => 'withdrawDate', 'columnName' => '交易日期', 'width' => 15, 'align' => Alignment::HORIZONTAL_LEFT], ['bindKey' => 'statusCn', 'columnName' => '订单状态', 'width' => 10, 'align' => Alignment::HORIZONTAL_LEFT], ['bindKey' => 'amount', 'columnName' => '订单金额(USD)', 'width' => 18, 'align' => Alignment::HORIZONTAL_RIGHT, 'format' => NumberFormat::FORMAT_NUMBER_00], ['bindKey' => 'cost', 'columnName' => '成本(USD)', 'width' => 18, 'align' => Alignment::HORIZONTAL_RIGHT, 'format' => NumberFormat::FORMAT_NUMBER_00], ['bindKey' => '={amount}-{cost}', 'columnName' => '收入(USD)', 'width' => 18, 'align' => Alignment::HORIZONTAL_RIGHT, 'format' => NumberFormat::FORMAT_NUMBER_00], ['bindKey' => '=({amount}-{cost})/{amount}', 'columnName' => '毛利率', 'width' => 18, 'align' => Alignment::HORIZONTAL_RIGHT, 'format' => NumberFormat::FORMAT_PERCENTAGE_00], ['bindKey' => 'uid', 'columnName' => '用户ID', 'width' => 30, 'align' => Alignment::HORIZONTAL_RIGHT], ['bindKey' => 'username', 'columnName' => '用户名', 'width' => 30, 'align' => Alignment::HORIZONTAL_LEFT], ['bindKey' => 'note', 'columnName' => '备注', 'width' => 30, 'align' => Alignment::HORIZONTAL_LEFT], ]; $filename = "收支明细" . date('YmdHis') . '.xlsx'; $fileFullpath = ExcelHelper::export($data, $config, $filename);
xianacg/exceler 适用场景与选型建议
xianacg/exceler 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 11 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「excel」 「PhpOffice」 「phpspreadsheet」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 xianacg/exceler 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 xianacg/exceler 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 xianacg/exceler 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
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
PHP Excel Library
Generate the column names for use in spreadsheets
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-06