• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

LICENSEH A D26-Oct-20201.1 KiB2116

README.mdH A D26-Oct-20203 KiB10084

xlsxwriter.class.phpH A D26-Oct-202046.7 KiB969839

README.md

1PHP_XLSXWriter
2==============
3
4This library is designed to be lightweight, and have minimal memory usage.
5
6It is designed to output an Excel compatible spreadsheet in (Office 2007+) xlsx format, with just basic features supported:
7* supports PHP 5.2.1+
8* takes UTF-8 encoded input
9* multiple worksheets
10* supports currency/date/numeric cell formatting, simple formulas
11* supports basic cell styling
12* supports writing huge 100K+ row spreadsheets
13
14[Never run out of memory with PHPExcel again](https://github.com/mk-j/PHP_XLSXWriter).
15
16Simple PHP CLI example:
17```php
18$data = array(
19    array('year','month','amount'),
20    array('2003','1','220'),
21    array('2003','2','153.5'),
22);
23
24$writer = new XLSXWriter();
25$writer->writeSheet($data);
26$writer->writeToFile('output.xlsx');
27```
28
29Simple/Advanced Cell Formats:
30```php
31$header = array(
32  'created'=>'date',
33  'product_id'=>'integer',
34  'quantity'=>'#,##0',
35  'amount'=>'price',
36  'description'=>'string',
37  'tax'=>'[$$-1009]#,##0.00;[RED]-[$$-1009]#,##0.00',
38);
39$data = array(
40    array('2015-01-01',873,1,'44.00','misc','=D2*0.05'),
41    array('2015-01-12',324,2,'88.00','none','=D3*0.05'),
42);
43
44$writer = new XLSXWriter();
45$writer->writeSheetHeader('Sheet1', $header );
46foreach($data as $row)
47	$writer->writeSheetRow('Sheet1', $row );
48$writer->writeToFile('example.xlsx');
49```
50
5150000 rows: (1.4s, 0MB memory usage)
52```php
53include_once("xlsxwriter.class.php");
54$writer = new XLSXWriter();
55$writer->writeSheetHeader('Sheet1', array('c1'=>'integer','c2'=>'integer','c3'=>'integer','c4'=>'integer') );
56for($i=0; $i<50000; $i++)
57{
58    $writer->writeSheetRow('Sheet1', array($i, $i+1, $i+2, $i+3) );
59}
60$writer->writeToFile('huge.xlsx');
61echo '#'.floor((memory_get_peak_usage())/1024/1024)."MB"."\n";
62```
63| rows   | time | memory |
64| ------ | ---- | ------ |
65|  50000 | 1.4s | 0MB    |
66| 100000 | 2.7s | 0MB    |
67| 150000 | 4.1s | 0MB    |
68| 200000 | 5.7s | 0MB    |
69| 250000 | 7.0s | 0MB    |
70
71Simple cell formats map to more advanced cell formats
72
73| simple formats | format code |
74| ---------- | ---- |
75| string   | @ |
76| integer  | 0 |
77| date     | YYYY-MM-DD |
78| datetime | YYYY-MM-DD HH:MM:SS |
79| price    | #,##0.00 |
80| dollar   | [$$-1009]#,##0.00;[RED]-[$$-1009]#,##0.00 |
81| euro     | #,##0.00 [$€-407];[RED]-#,##0.00 [$€-407] |
82
83
84Basic cell styles have been available since version 0.30
85
86| style        | allowed values |
87| ------------ | ---- |
88| font         | Arial, Times New Roman, Courier New, Comic Sans MS |
89| font-size    | 8,9,10,11,12 ... |
90| font-style   | bold, italic, underline, strikethrough or multiple ie: 'bold,italic' |
91| border       | left, right, top, bottom,   or multiple ie: 'top,left' |
92| border-style | thin, medium, thick, dashDot, dashDotDot, dashed, dotted, double, hair, mediumDashDot, mediumDashDotDot, mediumDashed, slantDashDot |
93| border-color | #RRGGBB, ie: #ff99cc or #f9c |
94| color        | #RRGGBB, ie: #ff99cc or #f9c |
95| fill         | #RRGGBB, ie: #eeffee or #efe |
96| halign       | general, left, right, justify, center |
97| valign       | bottom, center, distributed |
98
99
100