2017 © Pedro Peláez
 

symfony-bundle xls-bundle

Excel files manipulation for Symfony2

image

arodiss/xls-bundle

Excel files manipulation for Symfony2

  • Tuesday, December 26, 2017
  • by arodiss
  • Repository
  • 4 Watchers
  • 2 Stars
  • 18,390 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 1 Open issues
  • 23 Versions
  • 13 % Grown

The README.md

Xls Bundle

Trivia read and write of .xls files for Symfony2, built on top of the PHPExcel, (*1)

Installation

Via composer:, (*2)

require: {
    ...
    "arodiss/xls-bundle": "*@stable"
}

Usage examples:

Read a small file

$reader = $container->get("arodiss.xls.reader");
$content = $reader->readAll("/path/to/file.xls");
var_dump($content);
//array(2) =>
//    array(2) =>
//        0 => string(10) "First line"
//        1 => null
//    array(2) =>
//        0 => string(10) "Line number"
//        1 => int 2

Read a big file

Previous method can exhaust your memory if the file is big. However this is safe:, (*3)

$reader = $container->get("arodiss.xls.reader");
$iterator = $reader->getReadIterator("/path/to/file.xls");
while($iterator->valid())
{
    var_dump($iterator->current());
    $iterator->next();
}
//same output format

Read even a bigger file

Sometime PHPOffice just can't provide reasonable performance. For this case bundle provides alternative reader which wraps python implementation. It is rudimentary in terms of functionality and especially interactions (like error handling), but performs faster, especially on large files. In order to use it, you have to install openpyxl (for xlsx) and xlrd (for xls) libraries, which you can easily do through pip package manager, (*4)

$reader = $container->get("arodiss.xls.reader.python");
$iterator = $reader->getReadIterator("/path/to/file.xls");
while($iterator->valid())
{
    var_dump($iterator->current());
    $iterator->next();
}
//same output format

Return XLS file from Symfony controller

$file = $container
    ->get("arodiss.xls.builder")
    ->buildXlsFromArray(array(
        array("row one field one", "row one field two"),
        array("row two field one")
    ))
;

//now $file is path to tmp file with data

$response = new Response();
$response->headers->set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
$response->headers->set("Content-Disposition", "attachment;filename=excelfile.xlsx");
$response->setContent(file_get_contents($file));
return $response;
$writer = $container->get("arodiss.xls.writer.buffered");
$writer->create("users.xls", array("name", "email")); //second argument represents first row

foreach ($userProvider->getUsers() as $user) {
    $writer->appendRow("users.xls", array($user->getName(), $user->getEmail()));
}
$writer->flush();

Write operations for xls format are extremely expensive, so previous example uses BufferedWriter which stores your data in buffer and writes in file only once, when flushing the buffer. If for some reason this is not what you want to achieve, you may use service xls.writer in stead of xls.writer.buffered., (*5)

Formats supported

Files are always written in Excel2007 (.xlsx) format. Read operations, however, MAY work also for other formats supported by PHPExcel (Excel5, Office Open XML, SpreadsheetML, OASIS, CSV, Gnumeric, SYLK) however there is no guarantee for it., (*6)

The Versions

26/12 2017

dev-master

9999999-dev https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

by Sidora Gleb

excel xls export import

07/09 2017

v0.5.12

0.5.12.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

by Sidora Gleb

excel xls export import

03/03 2017

v0.5.11

0.5.11.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

by Sidora Gleb

excel xls export import

30/11 2016

v0.5.10

0.5.10.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

by Sidora Gleb

excel xls export import

05/08 2016

v0.5.9

0.5.9.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

by Sidora Gleb

excel xls export import

20/07 2016

v0.5.8

0.5.8.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

by Sidora Gleb

excel xls export import

20/07 2016

v0.5.7

0.5.7.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

by Sidora Gleb

excel xls export import

25/02 2016

v0.5.6

0.5.6.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

by Sidora Gleb

excel xls export import

25/02 2016

0.5.6

0.5.6.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

by Sidora Gleb

excel xls export import

23/12 2015

v0.5.5

0.5.5.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

by Sidora Gleb

excel xls export import

22/12 2015

v0.5.4

0.5.4.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

by Sidora Gleb

excel xls export import

21/12 2015

v0.5.3

0.5.3.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

by Sidora Gleb

excel xls export import

21/12 2015

v0.5.2

0.5.2.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

by Sidora Gleb

excel xls export import

17/12 2015

v0.5.1

0.5.1.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

by Sidora Gleb

excel xls export import

03/07 2015

v0.4.3

0.4.3.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sidora Gleb

excel xls export import

06/06 2015

v0.4.2

0.4.2.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sidora Gleb

excel xls export import

04/06 2015

v0.4.1

0.4.1.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sidora Gleb

excel xls export import

26/05 2015

v0.4

0.4.0.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sidora Gleb

excel xls export import

16/01 2015

0.3.1

0.3.1.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sidora Gleb

excel xls export import

04/12 2014

0.3

0.3.0.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sidora Gleb

excel xls export import

15/01 2014

0.2

0.2.0.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sidora Gleb

excel xls export import

08/12 2013

0.1.1

0.1.1.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sidora Gleb

excel xls export import

22/10 2013

0.1

0.1.0.0 https://github.com/arodiss/xls-bundle

Excel files manipulation for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sidora Gleb

excel xls export import