yakub/yxel
Composer 安装命令:
composer require yakub/yxel
包简介
This class help read and create new csv/xlsx files. Optimized for simple but big spreadsheet.
README 文档
README
This class help read and create new csv/xlsx files. Optimized for simple but big spreadsheet.
Build status
Install
The recommended way to install is via Composer:
composer require yakub/yxel
Settings
Class use tmp dir for create new files or read xlsx files. Path can be changed but script must have permissions for write in that folder.
\Yakub\Yxel\Main::setCreatingDir('/my/path/to/creating');
CSV
Simple work with csv file where is auto detection for separator between cells
Read csv file
$read = \Yakub\Yxel\Main::read('path/to/file.csv'); $read->getRows(function ($data, $row) { echo $row.' -> '.json_encode($data).'<br >'; });
Create csv file
$write = \Yakub\Yxel\Main::write('yxel_test', \Yakub\Yxel\Main::CSV); $write->addRow(['A1', 'B1', '']); $write->addRow(['A2', '', 'C2']); $write->close(); // Return full path to file $patToFile = $write->getFilePath();
XLSX
Simple work with xlsx file where is readed only first sheet
Read xlsx file
$read = \Yakub\Yxel\Main::read('path/to/file.xlsx'); $read->getRows(function ($data, $row) { echo $row.' -> '.json_encode($data).'<br >'; });
Create xlsx file
$write = \Yakub\Yxel\Main::write('yxel_test', \Yakub\Yxel\Main::XLSX); $write->addRow(['A1', 'B1', '']); $write->addRow(['A2', '', 'C2']); $write->close(); // Return full path to file $patToFile = $write->getFilePath();
Batch usage
Writing can be stopped and resumed later or in another process
$write = \Yakub\Yxel\Main::write('yxel_test', \Yakub\Yxel\Main::CSV); $write->addRow(['A1', 'B1', '']); $write->addRow(['A2', '', 'C2']); // Instead of close use save. This function only save new data but file is still able to get new rows. Also this help clean memory. // After save script can end and data will not be lost $write->save();
In other process just open existing file
// Name of file must be same $write = \Yakub\Yxel\Main::write('yxel_test', \Yakub\Yxel\Main::CSV); // Add new row to previous in this file $write->addRow(['', 'B3', 'C3']); // After close can't open this file again. If is used same name then file will be rewrited with new data $write->close();
To cominication between processes can use storage for custom data
$write = \Yakub\Yxel\Main::write('yxel_test', \Yakub\Yxel\Main::CSV); $write->addRow(['A1', 'B1', '']); $write->addRow(['A2', '', 'C2']); $write->settings('row_number', 3); $write->save(); // ------- New process ------- // $write = \Yakub\Yxel\Main::write('yxel_test', \Yakub\Yxel\Main::CSV); $row = $write->settings('row_number'); $write->addRow(['', 'B'.$row, 'C'.$row]); $write->close();
yakub/yxel 适用场景与选型建议
yakub/yxel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 06 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 yakub/yxel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yakub/yxel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 37
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2019-06-04