2017 © Pedro Peláez
 

project php_xlsxwriter

PHP Library to write XLSX files

image

mk-j/php_xlsxwriter

PHP Library to write XLSX files

  • Thursday, January 11, 2018
  • by mk-j
  • Repository
  • 80 Watchers
  • 703 Stars
  • 309,280 Installations
  • PHP
  • 16 Dependents
  • 0 Suggesters
  • 272 Forks
  • 68 Open issues
  • 14 Versions
  • 16 % Grown

The README.md

PHP_XLSXWriter

This library is designed to be lightweight, and have minimal memory usage., (*1)

It is designed to output an Excel compatible spreadsheet in (Office 2007+) xlsx format, with just basic features supported: * supports PHP 5.2.1+ * takes UTF-8 encoded input * multiple worksheets * supports currency/date/numeric cell formatting, simple formulas * supports basic cell styling * supports writing huge 100K+ row spreadsheets, (*2)

Never run out of memory with PHPExcel again., (*3)

Simple PHP CLI example:, (*4)

$data = array(
    array('year','month','amount'),
    array('2003','1','220'),
    array('2003','2','153.5'),
);

$writer = new XLSXWriter();
$writer->writeSheet($data);
$writer->writeToFile('output.xlsx');

Simple/Advanced Cell Formats:, (*5)

$header = array(
  'created'=>'date',
  'product_id'=>'integer',
  'quantity'=>'#,##0',
  'amount'=>'price',
  'description'=>'string',
  'tax'=>'[$$-1009]#,##0.00;[RED]-[$$-1009]#,##0.00',
);
$data = array(
    array('2015-01-01',873,1,'44.00','misc','=D2*0.05'),
    array('2015-01-12',324,2,'88.00','none','=D3*0.05'),
);

$writer = new XLSXWriter();
$writer->writeSheetHeader('Sheet1', $header );
foreach($data as $row)
    $writer->writeSheetRow('Sheet1', $row );
$writer->writeToFile('example.xlsx');

50000 rows: (1.4s, 0MB memory usage), (*6)

include_once("xlsxwriter.class.php");
$writer = new XLSXWriter();
$writer->writeSheetHeader('Sheet1', array('c1'=>'integer','c2'=>'integer','c3'=>'integer','c4'=>'integer') );
for($i=0; $i<50000; $i++)
{
    $writer->writeSheetRow('Sheet1', array($i, $i+1, $i+2, $i+3) );
}
$writer->writeToFile('huge.xlsx');
echo '#'.floor((memory_get_peak_usage())/1024/1024)."MB"."\n";
rows time memory
50000 1.4s 0MB
100000 2.7s 0MB
150000 4.1s 0MB
200000 5.7s 0MB
250000 7.0s 0MB

Simple cell formats map to more advanced cell formats, (*7)

simple formats format code
string @
integer 0
date YYYY-MM-DD
datetime YYYY-MM-DD HH:MM:SS
time HH:MM:SS
price #,##0.00
dollar [$$-1009]#,##0.00;[RED]-[$$-1009]#,##0.00
euro #,##0.00 [$€-407];[RED]-#,##0.00 [$€-407]

Basic cell styles have been available since version 0.30, (*8)

style allowed values
font Arial, Times New Roman, Courier New, Comic Sans MS
font-size 8,9,10,11,12 ...
font-style bold, italic, underline, strikethrough or multiple ie: 'bold,italic'
border left, right, top, bottom, or multiple ie: 'top,left'
border-style thin, medium, thick, dashDot, dashDotDot, dashed, dotted, double, hair, mediumDashDot, mediumDashDotDot, mediumDashed, slantDashDot
border-color #RRGGBB, ie: #ff99cc or #f9c
color #RRGGBB, ie: #ff99cc or #f9c
fill #RRGGBB, ie: #eeffee or #efe
halign general, left, right, justify, center
valign bottom, center, distributed

The Versions

11/01 2018

dev-master

9999999-dev https://github.com/mk-j/PHP_XLSXWriter

PHP Library to write XLSX files

  Sources   Download

MIT

The Requires

  • php >=5.2.1
  • ext-zip *

 

The Development Requires

php library excel xls xlsx

11/01 2018

dev-2018-06-0.38

dev-2018-06-0.38 https://github.com/mk-j/PHP_XLSXWriter

PHP Library to write XLSX files

  Sources   Download

MIT

The Requires

  • php >=5.2.1
  • ext-zip *

 

The Development Requires

php library excel xls xlsx

11/01 2018

0.37

0.37.0.0 https://github.com/mk-j/PHP_XLSXWriter

PHP Library to write XLSX files

  Sources   Download

MIT

The Requires

  • php >=5.2.1
  • ext-zip *

 

The Development Requires

php library excel xls xlsx

02/12 2017

dev-2017-12-0.37-r1

dev-2017-12-0.37-r1 https://github.com/mk-j/PHP_XLSXWriter

PHP Library to write XLSX files

  Sources   Download

MIT

The Requires

  • php >=5.2.1
  • ext-zip *

 

The Development Requires

php library excel xls xlsx

02/12 2017

0.36

0.36.0.0 https://github.com/mk-j/PHP_XLSXWriter

PHP Library to write XLSX files

  Sources   Download

MIT

The Requires

  • php >=5.2.1
  • ext-zip *

 

The Development Requires

php library excel xls xlsx

02/12 2017

dev-2017-09-0.36-r1

dev-2017-09-0.36-r1 https://github.com/mk-j/PHP_XLSXWriter

PHP Library to write XLSX files

  Sources   Download

MIT

The Requires

  • php >=5.2.1
  • ext-zip *

 

The Development Requires

php library excel xls xlsx

23/08 2017

0.35

0.35.0.0 https://github.com/mk-j/PHP_XLSXWriter

PHP Library to write XLSX files

  Sources   Download

MIT

The Requires

  • php >=5.2.1
  • ext-zip *

 

The Development Requires

php library excel xls xlsx

14/06 2017

dev-2017-07-0.35-rc1

dev-2017-07-0.35-rc1 https://github.com/mk-j/PHP_XLSXWriter

PHP Library to write XLSX files

  Sources   Download

MIT

The Requires

  • php >=5.2.1
  • ext-zip *

 

The Development Requires

php library excel xls xlsx

09/03 2017

0.32

0.32.0.0 https://github.com/mk-j/PHP_XLSXWriter

PHP Library to write XLSX files

  Sources   Download

MIT

The Requires

  • php >=5.2.1
  • ext-zip *

 

The Development Requires

php library excel xls xlsx

02/02 2017

0.31

0.31.0.0 https://github.com/mk-j/PHP_XLSXWriter

PHP Library to write XLSX files

  Sources   Download

MIT

The Requires

 

The Development Requires

php library excel xls xlsx

31/01 2017

0.30

0.30.0.0 https://github.com/mk-j/PHP_XLSXWriter

PHP Library to write XLSX files

  Sources   Download

MIT

The Requires

 

The Development Requires

php library excel xls xlsx

28/07 2015

0.22

0.22.0.0 https://github.com/mk-j/PHP_XLSXWriter

PHP Library to write XLSX files

  Sources   Download

MIT

The Development Requires

php library excel xls xlsx

18/11 2014

0.21

0.21.0.0 https://github.com/mk-j/PHP_XLSXWriter

PHP Library to write XLSX files

  Sources   Download

MIT

The Development Requires

php library excel xls xlsx

23/10 2014

0.20

0.20.0.0 https://github.com/mk-j/PHP_XLSXWriter

PHP Library to write XLSX files

  Sources   Download

MIT

php library excel xls xlsx