svrnm/exceldatatables 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

svrnm/exceldatatables

Composer 安装命令:

composer require svrnm/exceldatatables

包简介

Replace a worksheet within an Excel workbook (.xlsx) without changing any other properties of the file

README 文档

README

Replace a worksheet within an Excel workbook (.xlsx) without changing any other properties of the file.

License

This program is free software; see LICENSE for more details.

Details

The main purpose of this library is adding a "data table" to an existing excel file without modifying any other components. This is especially useful if you have a template file, e.g. for reporting including "advanced" features like charts, pivot tables, macros and you'd like to change a base data table within a PHP application.

Setup

Use composer to add this repository to your dependencies:

{
  "require": {
    "svrnm/exceldatatables": "dev-master"
  }
}

If you use the Laravel framework you can additionally add the ServiceProvider to your config/app.php:

...
'providers' => array(
  ...
  'Svrnm\ExcelDataTables\ExcelDataTablesServiceProvider'
)
...

Example

The following example demonstrates how to use ExcelDataTables. The following is also contained as example.php within the folder examples/:

<?php
  require_once('../vendor/autoload.php');
  // Create a new instance
  $dataTable = new Svrnm\ExcelDataTables\ExcelDataTable();
  // Specify the source file
  $in = 'spec.xlsx';
  // Specify the output file
  $out = 'test.xlsx';
  // Specify the data for the worksheet.
  $data = array(
    array("Date" => new \DateTime('2014-01-01 13:00:00'), "Value 1" => 0, "Value 2" => 1),
    array("Date" => new \DateTime('2014-01-02 14:00:00'), "Value 1" => 1, "Value 2" => 0),
    array("Date" => new \DateTime('2014-01-03 15:00:00'), "Value 1" => 2, "Value 2" => -1),
    array("Date" => new \DateTime('2014-01-04 16:00:00'), "Value 1" => 3, "Value 2" => -2),
    array("Date" => new \DateTime('2014-01-05 17:00:00'), "Value 1" => 4, "Value 2" => -3),
  );
  // Attach the data table and copy the new xlsx file to the output file.
  $dataTable->showHeaders()->addRows($data)->attachToFile($in, $out);
?>

In this example the method attachToFile creates a new excel file. If you use this library within a web application you might prefer the fillXLSX() function which returns a string representation of the excel document. The following examples demonstrates this case within a Laravel application

<?php
  class ReportController extends Controller {
    protected $dataTable;

     public function __construct(\Svrnm\ExcelDataTables\ExcelDataTable $dataTable) {
         $this->dataTable = $dataTable;
  }

  public function show($month) {
   $data = DB::select('select date,value1,value2 from reporting where MONTH(date) = ?', array($month));
   $path = storage_path() . '/reports/example.xlsx';
   $xlsx = $this->dataTable->showHeaders()->addRows($data)->fillXLSX($path);
   return Response::make($xlsx, 200, array(
    'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
    'Content-Disposition' => 'attachment; filename="report.xlsx"',
    'Content-Length' => strlen($xlsx)
   ));
   // ...
  }
 }
?>

Contact

For any questions you can contact Severin Neumann severin.neumann@altmuehlnet.de.

svrnm/exceldatatables 适用场景与选型建议

svrnm/exceldatatables 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 296.68k 次下载、GitHub Stars 达 30, 最近一次更新时间为 2016 年 04 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 svrnm/exceldatatables 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 296.68k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 30
  • 点击次数: 30
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 30
  • Watchers: 5
  • Forks: 18
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2016-04-20