GithubHelp home page GithubHelp logo

guoyu07 / oneexcel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from imtigger/oneexcel

0.0 0.0 0.0 103 KB

PHP Excel read/write abstraction layer, support PHPExcel, LibXL and Spout

License: MIT License

PHP 100.00%

oneexcel's Introduction

OneExcel

Build Status Latest Stable Version Latest Unstable Version Total Downloads License

PHP Excel read/write abstraction layer, support PHPExcel, LibXL, Spout and PHP fputcsv/fgetcsv

Targets to simplify server compatibility issue between Excel libraries and performance issue in huge files.

Ideal for simple-formatted but huge spreadsheet files such as reporting.

Installation

Requirements

  • PHP >= 5.6.4
  • php_zip, php_xmlreader, php_simplexml enabled
  • (Recommended) LibXL installed & php_excel enabled

Composer

OneExcel can only be installed from Composer.

Run the following command:

$ composer require imtigger/oneexcel

Writer

Documentations

Basic Usage

$excel = OneExcelWriterFactory::create()
        ->toFile('excel.xlsx')
        ->make();
        
$excel->writeCell(1, 0, 'Hello');
$excel->writeCell(2, 1, 'World');
$excel->writeCell(3, 2, 3.141592653, ColumnType::NUMERIC);
$excel->writeRow(4, ['One', 'Excel']);

$excel->output();

Advanced Usage

$excel = OneExcelWriterFactory::create()
        ->fromFile('template.xlsx', Format::XLSX)
        ->toStream('excel.csv', Format::CSV)
        ->withDriver(Driver::SPOUT)
        ->make();
        
$excel->writeCell(1, 0, 'Hello');
$excel->writeCell(2, 1, 'World');
$excel->writeCell(3, 2, 3.141592653, ColumnType::NUMERIC);
$excel->writeRow(4, ['One', 'Excel']);

$excel->output();

Reader

(Version 0.6+)

$excel = OneExcelReaderFactory::create()
        ->fromFile('excel.xlsx')
        // ->withDriver(Driver::SPOUT)
        ->make();
        
foreach ($excel->row() as $row) {
    //
}

$excel->close();

Known Issues

  • Spout reader driver output empty rows as SINGLE column (Upstream problem?)
  • Spout do not support random read/write rows (Upstream limitation, Won't fix)
  • Spout do not support formula (Upstream limitation, Won't fix)
  • fputcsv driver ignores all ColumnType::* (File-type limitation, Won't fix)

TODO

  • Register to Packagist
  • Emulate writeCell() behavior for Spout/fputcsv writer
  • OneExcelWriterFactory auto create writers base on input/output format
  • Refactor: Move constants to separate class
  • Implement load() for SpoutWriter and FPutCsvWriter
  • Implement $writer->writeRow($arr)
  • Implement ColumnType::NUMERIC, ColumnType::FORMULA for all drivers
  • Implement ColumnType::DATE, ColumnType::TIME, ColumnType::DATETIME for all drivers
  • Implement ColumnType::* for Spout driver (Require upstream update)
  • Implement sheet support
  • Implement Reader
  • Add PHPUnit tests

oneexcel's People

Contributors

atlas-wong avatar imtigger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.