定制 plumphp/plum-excel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

plumphp/plum-excel

最新稳定版本:v0.3

Composer 安装命令:

composer require plumphp/plum-excel

包简介

README 文档

README

Plum

PlumExcel includes readers and writers for Microsoft Excel files for Plum. Plum is a data processing pipeline for PHP.

Build Status Windows Build status Scrutinizer Code Quality Code Coverage StyleCI

Developed by Florian Eckerstorfer in Vienna, Europe.

Features

  • Read Microsoft Excel (.xlsx and .xls) files
  • Write Microsoft Excel (.xlsx and .xls) files
  • Uses PHPExcel

Installation

You can install plum-excel using Composer.

$ composer require plumphp/plum-excel

Usage

PlumExcel contains a reader and a writer for Plum. Please refer to the Plum documentation for more information about Plum.

You can also find examples of how to use ExcelReader and ExcelWriter in the examples/ folder.

Write Excel files

Writing Excel files is extremely simply. Just pass the filename of the file to the constructor. If you want to add a header row call the autoDetectHeader() method.

use Plum\PlumExcel\ExcelWriter;

$writer = new ExcelWriter(__DIR__.'/example.xlsx');
$writer->autoDetectHeader();

You can manually set the header names by calling the setHeader() method and passing an array with names.

$writer->setHeader(['Country Name', 'ISO 3166-1-alpha-2 code']);

However, if you want more control, you can also pass an instance of PHPExcel to the constructor and the format (Excel2007 or Excel5) or an implementation of PHPExcel_Writer_IWriter.

$writer = new ExcelWriter(__DIR__.'/example.xlsx', $excel, 'Excel2007', $writer);

Read Excel files

Reading Excel files is also pretty simple.

use Plum\PlumExcel\ExcelReader;

$reader = new ExcelReader(__DIR__.'/example.xlsx');

Instead of a filename you can also pass an instance of PHPExcel to the constructor.

use Plum\PlumExcel\ExcelReader;

$excel = PHPExcel_IOFactory::load(__DIR__.'/example.xlsx');
$reader = new ExcelReader($excel);

Plum can automatically detect the headers by using Plum\Plum\Converter\HeaderConverter.

use Plum\Plum\Converter\HeaderConverter;
use Plum\Plum\Filter\SkipFirstFilter;
use Plum\PlumExcel\ExcelReader;

$workflow->addConverter(new HeaderConverter());
$workflow->addFilter(new SkipFirstFilter(1));
$workflow->process(new ExcelReader($filename));

Change Log

Version 0.3 (24 October 2015)

  • #2 Handle items that are not arrays

Version 0.2.1 (28 April 2015)

  • Fix Plum version

Version 0.2 (22 April 2015)

  • ExcelReader supports filename as input
  • Add support for Plum\Plum\Reader\ReaderFactory

Version 0.1 (21 April 2015)

  • Initial release

License

The MIT license applies to plumphp/plum-excel. For the full copyright and license information, please view the LICENSE file distributed with this source code.

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-03-03