承接 ellumilel/php-excel-writer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ellumilel/php-excel-writer

Composer 安装命令:

composer require ellumilel/php-excel-writer

包简介

Big data Excel writer with small memory consuming

README 文档

README

Excel spreadsheet in with (Office 2007+) xlsx format, with just basic features

Build:

Latest Stable Version Latest Unstable Version Build Status Scrutinizer Code Quality License Total Downloads

Use:

Supports

  • supports PHP 5.4+
  • supports simple formulas
  • supports currency/date/numeric cell formatting
  • takes UTF-8 encoded input
  • multiple worksheets

Dev

  • PHPUnit
  • Optional: PHP_CodeSniffer for PSR-X-compatibility checks

Installation

The preferred way to install this extension is through composer. Either run

php composer.phar require --prefer-dist ellumilel/php-excel-writer

or add

"ellumilel/php-excel-writer": ">=0.1.3"

to the require section of your composer.json file.

Formats

  • 'string' = 'GENERAL'
  • 'text' = '@'
  • 'integer' = '0'
  • 'float_with_sep' = '#,##0.00'
  • 'float' = '0.00'
  • 'date' = 'YYYY-MM-DD'
  • 'datetime' = 'YYYY-MM-DD HH:MM:SS'
  • 'dollar' = '[$$-1009]#,##0.00;[RED]-[$$-1009]#,##0.00'
  • 'money' = '[$$-1009]#,##0.00;[RED]-[$$-1009]#,##0.00'
  • 'euro' = '#,##0.00 [$€-407];[RED]-#,##0.00 [$€-407]'
  • 'rub' = '#,##0.00 [$₽-419];[Red]-#,##0.00 [$₽-419]'
  • 'NN' = 'DDD'
  • 'NNN' = 'DDDD'
  • 'NNNN' = 'DDDD", "'

Examples

Simple:

$header = [
    'test1' => 'YYYY-MM-DD HH:MM:SS',
    'test2' => 'string',
    'test3' => 'string',
    'test4' => 'string',
    'test5' => 'string',
    'test6' => 'money',
];

$wExcel = new Ellumilel\ExcelWriter();
$wExcel->writeSheetHeader('Sheet1', $header);
$wExcel->setAuthor('Your name here');
for ($i = 0; $i < 5000; $i++) {
    $wExcel->writeSheetRow('Sheet1', [
        (new DateTime())->format('Y-m-d H:i:s'),
        rand(100, 10000),
        rand(100, 10000),
        rand(100, 10000),
        rand(100, 10000),
        rand(100, 10000),
    ]);
}

$wExcel->writeToFile("example.xlsx");

3.200.000 cell data example, low memory ~0.84 mb, fast write ~120 sec:

$header = [
    'head1' => 'YYYY-MM-DD HH:MM:SS',
    'head2' => 'string',
    'head3' => 'string',
    'head4' => 'string',
    'head5' => 'string',
    'head6' => 'string',
    'head7' => 'string',
    'head8' => 'text',
];
$wExcel = new Ellumilel\ExcelWriter();
$wExcel->setAuthor('BigData Tester');
$wExcel->writeSheetHeader('Sheet1', $header);
for ($ex = 0; $ex < 400000; $ex++) {
    $wExcel->writeSheetRow('Sheet1', [
        (new DateTime())->format('Y-m-d H:i:s'),
        'foo',
        'baz',
        'your text hear',
        rand(10000, 100000),
        rand(10000, 100000),
        rand(10000, 100000),
        rand(10000, 100000),
    ]);
}
$wExcel->writeToFile("output_big_data.xlsx");

Advanced formula/format:

$header = [
    'created' => 'date',
    'id' => 'integer',
    'count' => '#,##0',
    'amount' => 'dollar',
    'description' => 'string',
    'money' => '[$$-1009]#,##0.00;[RED]-[$$-1009]#,##0.00',
    'sum' => 'dollar',
    'rub' => 'rub',
];
$data = [
    [
        '2016-01-01',
        123,
        1002,
        '103.00',
        'short string',
        '=D2*0.15',
        '=DOLLAR('.rand(10000, 100000).', 2)',
        rand(10000, 100000),
    ],
    [
        '2016-04-12',
        234,
        2045,
        '2.00',
        'loooooong string',
        '=D3*0.15',
        '=DOLLAR('.rand(10000, 100000).', 2)',
        rand(10000, 100000),
    ],
    [
        '2016-02-05',
        45,
        56,
        '56.00',
        'loooooong loooooong string',
        '=D4*0.15',
        '=DOLLAR('.rand(10000, 100000).', 2)',
        rand(10000, 100000),
    ],
    [
        '2016-06-27',
        534,
        107,
        '678.00',
        'loooooong loooooongloooooong string',
        '=D5*0.15',
        '=DOLLAR('.rand(10000, 100000).', 2)',
        rand(10000, 100000),
    ],
];

$wExcel = new Ellumilel\ExcelWriter();
$wExcel->writeSheet($data, 'Sheet1', $header);
$wExcel->writeToFile('formulas.xlsx');

ellumilel/php-excel-writer 适用场景与选型建议

ellumilel/php-excel-writer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 311.14k 次下载、GitHub Stars 达 50, 最近一次更新时间为 2016 年 09 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「excel」 「spreadsheet」 「xlsx」 「export」 「php-excel」 「big-data」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ellumilel/php-excel-writer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ellumilel/php-excel-writer 我们能提供哪些服务?
定制开发 / 二次开发

基于 ellumilel/php-excel-writer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 311.14k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 51
  • 点击次数: 32
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 50
  • Watchers: 7
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-01