repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Calculation/TextData/VALUE.php
tests/data/Calculation/TextData/VALUE.php
<?php declare(strict_types=1); return [ [ '1000', '1000', ], [ '1000', '1 000', ], [ '1000', '$1 000', ], [ '#VALUE!', '£1 000', ], [ '1.1', '1.1', ], [ '1000.1', '1 000.1', ], [ '#VALUE!', '13 Monkeys', ], [ '41640', '1-Jan-2014', ], [ '0.524259259259259', '12:34:56', ], [ '0.11527777777778', '2:46 AM', ], 'no arguments' => ['exception'], 'bool argument' => ['#VALUE!', false], 'null argument' => ['0', null], 'issue 3574 null string invalid' => ['#VALUE!', ''], 'issue 3574 blank string invalid' => ['#VALUE!', ' '], 'issue 3574 non-blank numeric string okay' => [2, ' 2 '], 'issue 3574 non-blank non-numeric string invalid' => ['#VALUE!', ' x '], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Calculation/TextData/CHAR.php
tests/data/Calculation/TextData/CHAR.php
<?php declare(strict_types=1); return [ [ '#VALUE!', 'ABC', ], [ '#VALUE!', -5, ], [ '#VALUE!', 0, ], [ 'A', 65, ], [ '{', 123, ], [ '~', 126, ], [ ['Á', 'Á', '¡'], 193, ], [ ['ÿ', 'ÿ', 'ˇ'], 255, ], [ ['#VALUE!', 'Ā'], 256, ], [ ['#VALUE!', '⽇'], 12103, ], [ ['#VALUE!', 'œ'], 0x153, ], [ ['#VALUE!', 'ƒ'], 0x192, ], [ ['#VALUE!', '℅'], 0x2105, ], [ ['#VALUE!', '∑'], 0x2211, ], [ ['#VALUE!', '†'], 0x2020, ], 'example 1 different location all 3' => [ ['†', mb_chr(134, 'UTF-8'), 'Ü'], 134, ], 'example 2 different location all 3' => [ ['€', mb_chr(128, 'UTF-8'), 'Ä'], 128, ], 'non-ascii same win-1252 vs unicode, different mac' => [ ['Û', 'Û', '€'], 219, ], 'after currency symbol placeholder' => [ ['Ü', 'Ü', '‹'], 220, ], 'Example 3 where MAC differs from others' => [ ['Ð', 'Ð', '–'], 0xD0, ], 'last assigned Unicode character' => [ ['#VALUE!', mb_chr(0x10FFFD, 'UTF-8')], 0x10FFFD, ], 'highest possible code point' => [ ['#VALUE!', '#N/A'], 0x10FFFF, ], 'above highest possible code point' => [ '#VALUE!', 0x110000, ], 'nbsp for win/uni, dagger for Mac' => [ ["\u{A0}", "\u{A0}", '†'], 160, ], 'omitted argument' => ['exception'], 'non-printable' => ["\x02", 2], 'bool argument' => ["\x01", true], 'null argument' => ['#VALUE!', null], 'ascii 1 is 49' => ['1', 49], 'ascii 0 is 48' => ['0', 48], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Calculation/TextData/NUMBERVALUE.php
tests/data/Calculation/TextData/NUMBERVALUE.php
<?php declare(strict_types=1); return [ [ 1234567.89, '1,234,567.890', ], [ 1234567.89, '1 234 567,890', ',', ' ', ], [ -1234567.89, '-1 234 567,890', ',', ' ', ], [ '#VALUE!', '1 234 567,890-', ',', ' ', ], [ '#VALUE!', '1,234,567.890,123', ], [ '#VALUE!', '1.234.567.890,123', ], [ 1234567.890, '1.234.567,890', ',', '.', ], [ '#VALUE!', '1.234.567,89', ], [ 12345.6789, '1,234,567.89%', ], [ 123.456789, '1,234,567.89%%', ], [ 1.23456789, '1,234,567.89%%%', ], [ '#VALUE!', '1,234,567.89-%', ], 'no arguments' => ['exception'], 'boolean argument' => ['#VALUE!', true], 'slash as group separator' => [1234567.1, '1/234/567.1', '.', '/'], 'slash as decimal separator' => [1234567.1, '1,234,567/1', '/', ','], 'issue 3574 null string treated as 0' => [0, '', ',', ' '], 'issue 3574 one or more spaces treated as 0' => [0, ' ', ',', ' '], 'issue 3574 non-blank numeric string okay' => [2, ' 2 ', ',', ' '], 'issue 3574 non-blank non-numeric string invalid' => ['#VALUE!', ' x ', ',', ' '], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Calculation/TextData/PROPER.php
tests/data/Calculation/TextData/PROPER.php
<?php declare(strict_types=1); return [ [ 'Mark Baker', 'MARK BAKER', ], [ 'Buenos Días', 'BUENOS DÍAS', ], [ 'Καλημερα', 'ΚΑΛΗΜΕΡΑ', ], [ 'Доброе Утро', 'ДОБРОЕ УТРО', ], [ 'True', true, ], [ 'False', false, ], 'error code unchanged' => [ '#VALUE!', '#VALUE!', ], 'no argument' => ['exception'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Calculation/TextData/FIXED.php
tests/data/Calculation/TextData/FIXED.php
<?php declare(strict_types=1); return [ [ '123,456.79', 123456.789, 2, false, ], [ '123456.8', 123456.789, 1, true, ], [ '123456.79', 123456.789, 2, true, ], [ '-123456.79', -123456.789, 2, true, ], [ '123500', 123456.789, -2, true, ], [ '123,500', 123456.789, -2, ], [ '-123500', -123456.789, -2, true, ], [ '-123,500', -123456.789, -2, ], [ '#VALUE!', 'ABC', 2, null, ], [ '#VALUE!', 123.456, 'ABC', null, ], 'no arguments' => ['exception'], 'just one argument is okay' => ['123.00', 123], 'null second argument' => ['123', 123, null], 'false second argument' => ['123', 123, false], 'true second argument' => ['123.0', 123, true], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Calculation/TextData/ARRAYTOTEXT.php
tests/data/Calculation/TextData/ARRAYTOTEXT.php
<?php declare(strict_types=1); return [ [ "1, 2, 3, a, b, c, TRUE, FALSE, #DIV/0!, 44774, 1, 44777, 12345.6789, -2.4, Hello\nWorld", [ [1, 2, 3], ['a', 'b', 'c'], [true, false, '=12/0'], ['=DATE(2022,8,1)', '1', '=A4+3'], [12345.6789, '=-12/5', "Hello\nWorld"], ], 0, ], [ "{1,2,3;\"a\",\"b\",\"c\";TRUE,FALSE,#DIV/0!;44774,1,44777;12345.6789,-2.4,\"Hello\nWorld\"}", [ [1, 2, 3], ['a', 'b', 'c'], [true, false, '=12/0'], ['=DATE(2022,8,1)', 1, '=A4+3'], [12345.6789, '=-12/5', "Hello\nWorld"], ], 1, ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Calculation/TextData/CONCAT.php
tests/data/Calculation/TextData/CONCAT.php
<?php declare(strict_types=1); use PhpOffice\PhpSpreadsheet\Cell\DataType; return [ [ 'ABCDEFGHIJ', 'ABCDE', 'FGHIJ', ], [ '123', 1, 2, 3, ], [ 'Boolean-TRUE', 'Boolean', '-', true, ], 'no arguments' => ['exception'], 'result just fits' => [ // Note use Armenian character below to make sure chars, not bytes str_repeat('Ԁ', DataType::MAX_STRING_LENGTH - 5) . 'ABCDE', str_repeat('Ԁ', DataType::MAX_STRING_LENGTH - 5), 'ABCDE', ], 'result too long' => [ '#CALC!', str_repeat('Ԁ', DataType::MAX_STRING_LENGTH - 5), 'abc', '=A2', ], 'propagate DIV0' => ['#DIV/0!', '1', '=2/0', '3'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Calculation/TextData/SEARCH.php
tests/data/Calculation/TextData/SEARCH.php
<?php declare(strict_types=1); return [ [ 3, 'E', 'QWERTYUIOP', ], [ 4, 'D', 'ABCDEFGHI', ], [ 4, 'E', true, ], [ 5, 'E', false, ], [ 2, 'A', 'Mark Baker', ], [ '#VALUE!', 'C', 'Mark Baker', ], [ 7, 'A', 'Mark Baker', 3, ], [ 4, 'K', 'Mark Baker', ], [ 8, 'K', 'Mark Baker', 5, ], [ 2, 'A', 'Mark Baker', 2, ], [ 1, '', 'Mark Baker', ], [ 1, 'Ενα', 'Ενα δύο τρία τέσσερα πέντε', ], [ 9, 'τρία', 'Ενα δύο τρία τέσσερα πέντε', ], [ 22, 'πέντε', 'Ενα δύο τρία τέσσερα πέντε', ], [ 1, 'Ενα', 'ΕΝΑ ΔΥΟ ΤΡΙΑ ΤΕΣΣΕΡΑ ΠΕΝΤΕ', ], [ 9, 'τρία', 'ΕΝΑ ΔΎΟ ΤΡΊΑ ΤΈΣΣΕΡΑ ΠΈΝΤΕ', ], [ 22, 'πέντε', 'ΕΝΑ ΔΎΟ ΤΡΊΑ ΤΈΣΣΕΡΑ ΠΈΝΤΕ', ], [ '#VALUE!', 'BITE', 'BIT', ], 'Boolean Needle' => [ '#VALUE!', true, 'Mark Baker', ], 'no arguments' => ['exception'], 'one argument' => ['exception', 'string'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Calculation/TextData/OpenOffice.php
tests/data/Calculation/TextData/OpenOffice.php
<?php declare(strict_types=1); return [ 'OO allows CHAR(0)' => ["\x00", '=CHAR(0)'], 'OO treats CODE(bool) as 0/1' => [48, '=CODE(FALSE)'], 'OO treats UNICODE(bool) as 0/1' => [49, '=UNICODE(TRUE)'], 'OO treats bool as string as 0/1 to REPT' => ['111', '=REPT(true, 3)'], 'OO treats bool as string as 0/1 to CLEAN' => ['0', '=CLEAN(false)'], 'OO treats bool as string as 0/1 to TRIM' => ['1', '=TRIM(true)'], 'OO treats bool as string as 0/1 to LEN' => [1, '=LEN(false)'], 'OO treats bool as string as 0/1 to EXACT parm 1' => [true, '=EXACT(true, 1)'], 'OO treats bool as string as 0/1 to EXACT parm 2' => [true, '=EXACT(0, false)'], 'OO treats bool as string as 0/1 to FIND parm 1' => [2, '=FIND(true, "210")'], 'OO treats bool as string as 0/1 to FIND parm 2' => [1, '=FIND(0, false)'], 'OO treats true as int 1 to FIND parm 3' => [1, '=FIND("a", "aba", true)'], 'OO treats false as int 0 to FIND parm 3' => ['#VALUE!', '=FIND("a", "aba", false)'], 'OO treats bool as string as 0/1 to SEARCH parm 1' => [2, '=SEARCH(true, "210")'], 'OO treats bool as string as 0/1 to SEARCH parm 2' => [1, '=SEARCH(0, false)'], 'OO treats true as int 1 to SEARCH parm 3' => [1, '=SEARCH("a", "aba", true)'], 'OO treats false as int 0 to SEARCH parm 3' => ['#VALUE!', '=SEARCH("a", "aba", false)'], 'OO treats true as 1 to REPLACE parm 1' => ['10', '=REPLACE(true, 3, 1, false)'], 'OO treats false as 0 to REPLACE parm 4' => ['he0lo', '=REPLACE("hello", 3, 1, false)'], 'OO treats false as 0 SUBSTITUTE parm 1' => ['6', '=SUBSTITUTE(true, "1", "6")'], 'OO treats true as 1 SUBSTITUTE parm 4' => ['zbcade', '=SUBSTITUTE("abcade", "a", "z", true)'], 'OO TEXT boolean in lieu of string' => ['0', '=TEXT(false, "@")'], 'OO VALUE boolean in lieu of string' => [0.0, '=VALUE(false)'], 'OO NUMBERVALUE boolean in lieu of string' => [1.0, '=NUMBERVALUE(true)'], 'OO TEXTJOIN boolean in lieu of string' => ['1-0-1', '=TEXTJOIN("-", true, true, false, true)'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Calculation/TextData/TEXT.php
tests/data/Calculation/TextData/TEXT.php
<?php declare(strict_types=1); return [ [ '$123.46', 123.456, '$#,##0.00', ], [ '$-123.46', -123.456, '$#,##0.00', ], [ '123.46', 123.456, '#,##0.00', ], [ '123', 123.456, '#,##0', ], [ '00123', 123.456, '00000', ], [ '$123,456.79', 123456.789, '$#,##0.00', ], [ '123,456.79', 123456.789, '#,##0.00', ], [ '1.23E+5', 123456.789, '0.00E+00', ], [ '-1.23E+5', -123456.789, '0.00E+00', ], [ '1.23E-5', 1.2345E-5, '0.00E+00', ], [ '1960-12-19', '19-Dec-1960', 'yyyy-mm-dd', ], [ '2012-01-01', '1-Jan-2012', 'yyyy-mm-dd', ], 'time (issue 3409)' => [ '09:01:00', '09:01', 'HH:MM:SS', ], 'datetime' => [ '15-Feb-2014 04:17:00 PM', '2014-02-15 16:17', 'dd-mmm-yyyy HH:MM:SS AM/PM', ], 'datetime integer' => [ '1900-01-06 00:00', 6, 'yyyy-mm-dd hh:mm', ], 'datetime integer as string' => [ '1900-01-06 00:00', '6', 'yyyy-mm-dd hh:mm', ], 'datetime 2 integers without date delimiters' => [ '5 6', '5 6', 'yyyy-mm-dd hh:mm', ], 'datetime 2 integers separated by hyphen' => [ (new DateTimeImmutable())->format('Y') . '-05-13 00:00', '5-13', 'yyyy-mm-dd hh:mm', ], 'datetime string date only' => [ '1951-01-23 00:00', 'January 23, 1951', 'yyyy-mm-dd hh:mm', ], 'datetime string time followed by date' => [ '1952-05-02 03:54', '3:54 May 2, 1952', 'yyyy-mm-dd hh:mm', ], 'datetime string date followed by time pm' => [ '1952-05-02 15:54', 'May 2, 1952 3:54 pm', 'yyyy-mm-dd hh:mm', ], 'datetime string date followed by time p' => [ '1952-05-02 15:54', 'May 2, 1952 3:54 p', 'yyyy-mm-dd hh:mm', ], 'datetime decimal string interpreted as time' => [ '1900-01-02 12:00', '2.5', 'yyyy-mm-dd hh:mm', ], 'datetime unparseable string' => [ 'xyz', 'xyz', 'yyyy-mm-dd hh:mm', ], [ '1 3/4', 1.75, '# ?/?', ], 'no arguments' => ['exception'], 'one argument' => ['exception', 1.75], 'boolean in lieu of string' => ['TRUE', true, '@'], 'system long date format' => ['Sunday, January 1, 2012', '1-Jan-2012', '[$-x-sysdate]'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Calculation/TextData/RIGHT.php
tests/data/Calculation/TextData/RIGHT.php
<?php declare(strict_types=1); return [ [ '', null, 1, ], [ '', '', 1, ], [ '#VALUE!', 'QWERTYUIOP', -1, ], [ '#VALUE!', 'QWERTYUIOP', 'NaN', ], 'null length defaults to 0' => [ '', 'QWERTYUIOP', null, ], 'omitted length defaults to 1' => [ 'P', 'QWERTYUIOP', ], [ 'GHI', 'ABCDEFGHI', 3, ], [ '', 'ABCDEFGHI', 0, ], [ 'πέντε', 'Ενα δύο τρία τέσσερα πέντε', 5, ], [ 'τέσσερα πέντε', 'Ενα δύο τρία τέσσερα πέντε', 13, ], [ 'τρία τέσσερα πέντε', 'Ενα δύο τρία τέσσερα πέντε', 18, ], [ 'UE', true, 2, ], [ 'SE', false, 2, ], 'string not specified' => [ 'exception', ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Calculation/TextData/CONCATENATE.php
tests/data/Calculation/TextData/CONCATENATE.php
<?php declare(strict_types=1); use PhpOffice\PhpSpreadsheet\Cell\DataType; return [ /*[ 'ABCDEFGHIJ', 'ABCDE', 'FGHIJ', ], [ '123', 1, 2, 3, ], [ 'Boolean-TRUE', 'Boolean', '-', true, ], 'no arguments' => ['exception'], 'result just fits' => [ // Note use Armenian character below to make sure chars, not bytes str_repeat('Ԁ', DataType::MAX_STRING_LENGTH - 5) . 'ABCDE', 'A3', 'ABCDE', ], 'result too long' => [ '#CALC!', 'A3', 'abc', 'def', ],*/ 'propagate DIV0' => ['#DIV/0!', '1', 'A2', '3'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Calculation/TextData/TEXTSPLIT.php
tests/data/Calculation/TextData/TEXTSPLIT.php
<?php declare(strict_types=1); use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; return [ [ [['Hello', 'World']], [ 'Hello World', ' ', '', ], ], [ [['Hello'], ['World']], [ 'Hello World', '', ' ', ], ], [ [['To', 'be', 'or', 'not', 'to', 'be']], [ 'To be or not to be', ' ', '', ], ], [ [ ['1', '2', '3'], ['4', '5', '6'], ], [ '1,2,3;4,5,6', ',', ';', ], ], [ [ ['Do', ' Or do not', ' There is no try', ' ', 'Anonymous'], ], [ 'Do. Or do not. There is no try. -Anonymous', ['.', '-'], '', ], ], [ [['Do'], [' Or do not'], [' There is no try'], [' '], ['Anonymous']], [ 'Do. Or do not. There is no try. -Anonymous', '', ['.', '-'], ], ], [ [ ['Do', ' Or do not', ' There is no try', ' '], ['Anonymous', ExcelError::NA(), ExcelError::NA(), ExcelError::NA()], ], [ 'Do. Or do not. There is no try. -Anonymous', '.', '-', ], ], [ [ ['', '', '1'], ['', '', ExcelError::NA()], ['', '2', ''], ['3', ExcelError::NA(), ExcelError::NA()], ['', ExcelError::NA(), ExcelError::NA()], ['', '4', ExcelError::NA()], ], [ '--1|-|-2-|3||-4', '-', '|', ], ], [ [ ['1'], ['2'], ['3'], ['4'], ], [ '--1|-|-2-|3||-4', '-', '|', true, ], ], [ [['', 'BCD', 'FGH', 'JKLMN', 'PQRST', 'VWXYZ']], [ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', ['A', 'E', 'I', 'O', 'U'], '', ], ], 'slash as column delimiter' => [ [['Hello', 'World']], [ 'Hello/World', '/', '', ], ], 'slash as row delimiter' => [ [['ho', 'w'], ['about', '#N/A'], ['t', 'hat']], [ 'ho.w/about/t.hat', '.', '/', ], ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Calculation/TextData/REPLACE.php
tests/data/Calculation/TextData/REPLACE.php
<?php declare(strict_types=1); return [ [ 'QWDFGYUIOP', 'QWERTYUIOP', 3, 3, 'DFG', ], [ 'QWERDFGIOP', 'QWERTYUIOP', 5, 3, 'DFG', ], [ 'QWDFGERTYUIOP', 'QWERTYUIOP', 3, 0, 'DFG', ], [ 'QWERDFGTYUIOP', 'QWERTYUIOP', 5, 0, 'DFG', ], [ 'Ενα δύοτρίατέσσεραπέντε', 'Εναδύοτρίατέσσεραπέντε', 4, 0, ' ', ], [ 'Ενα δύο τρίατέσσεραπέντε', 'Ενα δύοτρίατέσσεραπέντε', 8, 0, ' ', ], [ 'Ενα δύο τρία τέσσεραπέντε', 'Ενα δύο τρίατέσσεραπέντε', 13, 0, ' ', ], [ 'Ενα δύο τρία τέσσερα πέντε', 'Ενα δύο τρία τέσσεραπέντε', 21, 0, ' ', ], 'no arguments' => ['exception'], 'one argument' => ['exception', 'hello'], 'two arguments' => ['exception', 'hello', 2], 'three arguments' => ['exception', 'hello', 2, 2], 'position zero' => ['#VALUE!', 'hello', 0, 2, 'xyz'], 'negative length' => ['#VALUE!', 'hello', 3, -1, 'xyz'], 'boolean 1st parm' => ['TRDFGE', true, 3, 1, 'DFG'], 'boolean 4th parm' => ['heFALSElo', 'hello', 3, 1, false], 'propagate REF' => ['#REF!', '=sheet99!A1', 3, 1, 'x'], 'propagate DIV0' => ['#DIV/0!', '=1/0', 3, 1, 'x'], 'string which just sneaks in' => [ str_repeat('A', 32766) . 'C', str_repeat('A', 32766) . 'B', 32767, '1', 'C', ], 'string which overflows' => [ '#VALUE!', str_repeat('A', 32766) . 'B', 32767, '1', 'CC', ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Functional/TypeAttributePreservation/Formula.php
tests/data/Functional/TypeAttributePreservation/Formula.php
<?php declare(strict_types=1); return [ [ ['string'], ], [ ['="string"'], ], [ [1], ], [ [0], ], [ [true], ], [ [false], ], [ ['=TRUE()'], ], [ ['=ISFORMULA(B1)', '=1+2'], ], [ ['1'], ], [ ['0'], ], [ ['null'], ], [ [null], ], 'issue3568' => [ ['="00"&B1', '123'], ], 'unimplemented function' => [ ['=INFO("SYSTEM")'], ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/ConvertFormulaToA1FromR1C1Relative.php
tests/data/Cell/ConvertFormulaToA1FromR1C1Relative.php
<?php declare(strict_types=1); return [ 'Basic addition' => ['=D3+F7+G4+C6+5', '=R[-2]C[-1]+R[2]C[1]+R[-1]C[2]+R[1]C[-2]+5', 5, 5], 'Basic subtraction' => ['=D3-F7-G4-C6-5', '=R[-2]C[-1]-R[2]C[1]-R[-1]C[2]-R[1]C[-2]-5', 5, 5], 'Basic multiplication' => ['=D3*F7*G4*C6*5', '=R[-2]C[-1]*R[2]C[1]*R[-1]C[2]*R[1]C[-2]*5', 5, 5], 'Basic division' => ['=D3/F7/G4/C6/5', '=R[-2]C[-1]/R[2]C[1]/R[-1]C[2]/R[1]C[-2]/5', 5, 5], 'Basic addition with current row/column' => ['=E3+E7+G5+C5+E5+5', '=R[-2]C+R[2]C+RC[2]+RC[-2]+RC+5', 5, 5], 'Basic subtraction with current row/column' => ['=E3-E7-G5-C5-E5-5', '=R[-2]C-R[2]C-RC[2]-RC[-2]-RC-5', 5, 5], 'Basic multiplication with current row/column' => ['=E3*E7*G5*C5*E5*5', '=R[-2]C*R[2]C*RC[2]*RC[-2]*RC*5', 5, 5], 'Basic division with current row/column' => ['=E3/E7/G5/C5/E5/5', '=R[-2]C/R[2]C/RC[2]/RC[-2]/RC/5', 5, 5], 'Simple formula' => ['=SUM(E1:E5)', '=SUM(R[-4]C:RC)', 5, 5], 'Formula with range and cell' => ['=SUM(E1:E5, D5)', '=SUM(R[-4]C:RC, RC[-1])', 5, 5], 'Formula arithmetic' => ['=SUM(E1:E5, D5)-C5', '=SUM(R[-4]C:RC, RC[-1])-RC[-2]', 5, 5], 'Formula with comparison' => ['=IF(E1>E2, E3, E4)', '=IF(R[-4]C>R[-3]C, R[-2]C, R[-1]C)', 5, 5], 'String literal' => ['=CONCAT("Result of formula expression =R[-2]C[-2]+R[-1]C[-2] is: ", C3+C4)', '=CONCAT("Result of formula expression =R[-2]C[-2]+R[-1]C[-2] is: ", R[-2]C[-2]+R[-1]C[-2])', 5, 5], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/CoordinateIsInsideRange.php
tests/data/Cell/CoordinateIsInsideRange.php
<?php declare(strict_types=1); return [ [true, 'A1:E20', 'B4'], [false, 'A1:E20', 'F36'], [true, '$A$1:$E$20', '$B$4'], [false, '$A$1:$E$20', '$F$36'], [true, '$A$1:$E$20', 'B4'], [false, '$A$1:$E$20', 'F36'], [true, 'A1:E20', '$B$4'], [false, 'A1:E20', '$F$36'], [true, 'Sheet!A1:E20', 'Sheet!B4'], 'case insensitive' => [true, 'Sheet!A1:E20', 'sheet!B4'], 'apostrophes 1st sheetname not 2nd' => [true, '\'Sheet\'!A1:E20', 'sheet!B4'], 'apostrophes 2nd sheetname not 1st' => [true, 'Sheet!A1:E20', '\'sheet\'!B4'], [false, 'Sheet!A1:E20', 'Sheet!F36'], [true, 'Sheet!$A$1:$E$20', 'Sheet!$B$4'], [false, 'Sheet!$A$1:$E$20', 'Sheet!$F$36'], [false, 'Sheet!A1:E20', 'B4'], [false, 'Sheet!A1:E20', 'F36'], [false, 'Sheet!$A$1:$E$20', '$B$4'], [false, 'Sheet!$A$1:$E$20', '$F$36'], [false, 'A1:E20', 'Sheet!B4'], [false, 'A1:E20', 'Sheet!F36'], [false, '$A$1:$E$20', 'Sheet!$B$4'], [false, '$A$1:$E$20', 'Sheet!$F$36'], [true, '\'Sheet space\'!A1:E20', '\'Sheet space\'!B4'], [false, '\'Sheet space\'!A1:E20', '\'Sheet space\'!F36'], [true, '\'Sheet space\'!$A$1:$E$20', '\'Sheet space\'!$B$4'], [false, '\'Sheet space\'!$A$1:$E$20', '\'Sheet space\'!$F$36'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/R1C1ConversionToA1Relative.php
tests/data/Cell/R1C1ConversionToA1Relative.php
<?php declare(strict_types=1); return [ ['C3', 'R[2]C[2]'], ['O18', 'R[2]C[2]', 16, 13], ['O14', 'R[-2]C[2]', 16, 13], ['K18', 'R[2]C[-2]', 16, 13], ['K14', 'R[-2]C[-2]', 16, 13], ['P16', 'RC[3]', 16, 13], ['J16', 'RC[-3]', 16, 13], ['M20', 'R[4]C', 16, 13], ['M12', 'R[-4]C', 16, 13], ['E5', 'RC', 5, 5], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/SetValueExplicit.php
tests/data/Cell/SetValueExplicit.php
<?php declare(strict_types=1); use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PhpOffice\PhpSpreadsheet\Cell\DataType; return [ [ 1234567890123456789, '01234567890123456789', DataType::TYPE_NUMERIC, ], [ 1234567890123456789, 1234567890123456789, DataType::TYPE_NUMERIC, ], [ 123.456, '123.456', DataType::TYPE_NUMERIC, ], [ 123.456, 123.456, DataType::TYPE_NUMERIC, ], [ 0, null, DataType::TYPE_NUMERIC, ], [ 0, false, DataType::TYPE_NUMERIC, ], [ 1, true, DataType::TYPE_NUMERIC, ], [ 44613.43090277778, '2022-02-21 10:20:30', DataType::TYPE_ISO_DATE, ], [ 44613.0, '2022-02-21', DataType::TYPE_ISO_DATE, ], [ -30879.0, '1815-06-15', // Dates outside the Excel Range should fail really DataType::TYPE_ISO_DATE, ], [ ExcelError::DIV0(), '#DIV/0!', DataType::TYPE_ERROR, ], [ ExcelError::null(), 'NOT A VALID ERROR TYPE VALUE', DataType::TYPE_ERROR, ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/ConvertFormulaToA1FromSpreadsheetXml.php
tests/data/Cell/ConvertFormulaToA1FromSpreadsheetXml.php
<?php declare(strict_types=1); return [ 'Basic addition' => ['=D3+F7+G4+C6+5', 'of:=[.D3]+[.F7]+[.G4]+[.C6]+5'], 'Basic subtraction' => ['=D3-F7-G4-C6-5', 'of:=[.D3]-[.F7]-[.G4]-[.C6]-5'], 'Basic multiplication' => ['=D3*F7*G4*C6*5', 'of:=[.D3]*[.F7]*[.G4]*[.C6]*5'], 'Basic division' => ['=D3/F7/G4/C6/5', 'of:=[.D3]/[.F7]/[.G4]/[.C6]/5'], 'Simple formula' => ['=SUM(E1:E5)', 'of:=SUM([.E1:.E5])'], 'Formula with range and cell' => ['=SUM(E1:E5, D5)', 'of:=SUM([.E1:.E5], [.D5])'], 'Formula arithmetic' => ['=SUM(E1:E5, D5)-C5', 'of:=SUM([.E1:.E5], [.D5])-[.C5]'], 'Formula with comparison' => ['=IF(E1>E2, E3, E4)', 'of:=IF([.E1]>[.E2], [.E3], [.E4])'], 'String literal' => ['=CONCAT("Result of formula expression =[.C3]+[.C4] is: ", C3+C4)', 'of:=CONCAT("Result of formula expression =[.C3]+[.C4] is: ", [.C3]+[.C4])'], 'Simple numeric addition' => ['=1.23+2.34', 'of:=1.23+2.34'], 'More complex formula with cells and numeric literals' => ['=D3+F7+G4+C6+5.67', 'of:=[.D3]+[.F7]+[.G4]+[.C6]+5.67'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/SetValueExplicitTypeArguments.php
tests/data/Cell/SetValueExplicitTypeArguments.php
<?php declare(strict_types=1); use PhpOffice\PhpSpreadsheet\Cell\DataType; // This member will be used to validate both: // Cell::setValueExplicit // Worksheet::setCellValueExplicit return [ 'string with default type' => ['default string', null, 'default string', DataType::TYPE_STRING], 'integer with default type' => [42, null, '42', DataType::TYPE_STRING], 'string with string' => ['explicit string', DataType::TYPE_STRING, 'explicit string', DataType::TYPE_STRING], 'integer with string type' => [123, DataType::TYPE_STRING, '123', DataType::TYPE_STRING], 'numeric string with string type' => ['496', DataType::TYPE_STRING, '496', DataType::TYPE_STRING], 'integer with numeric type' => [591, DataType::TYPE_NUMERIC, 591, DataType::TYPE_NUMERIC], 'numeric string with numeric type' => ['1887', DataType::TYPE_NUMERIC, 1887, DataType::TYPE_NUMERIC], 'true with bool type' => [true, DataType::TYPE_BOOL, true, DataType::TYPE_BOOL], 'false with bool type' => [false, DataType::TYPE_BOOL, false, DataType::TYPE_BOOL], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/DefaultValueBinder.php
tests/data/Cell/DefaultValueBinder.php
<?php declare(strict_types=1); return [ [ 'null', null, ], [ 'e', '#NULL!', ], [ 'b', false, ], [ 'b', true, ], [ 's', 'FALSE', ], [ 's', 'TRUE', ], [ 's', '', ], [ 's', 'ABC', ], [ 'n', '123', ], [ 'n', 123, ], [ 'n', 0.123, ], [ 'n', '-123', ], [ 'n', '1.23E4', ], [ 'n', '-1.23E4', ], [ 'n', '1.23E-4', ], [ 's', '000123', ], [ 'f', '=123', ], [ 'e', '#DIV/0!', ], [ 's', '123456\n', ], 'Numeric that exceeds PHP MAX_INT Size' => [ 's', '1234567890123459012345689012345690', ], 'Issue 1310 Multiple = at start' => ['s', '======'], 'Issue 1310 Variant 1' => ['s', '= ====='], 'Issue 1310 Variant 2' => ['s', '=2*3='], 'Issue 4766 very large positive exponent treated as string' => ['s', '4E433'], 'Issue 4766 very large negative exponent numeric' => ['n', '4E-433'], 'Issue 4766 small exponent no decimal point numeric' => ['n', '4E4'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/IndexesFromString.php
tests/data/Cell/IndexesFromString.php
<?php declare(strict_types=1); return [ [ [ 1, 1, 'A', ], 'A1', ], [ [ 1, 12, 'A', ], 'A12', ], [ [ 10, 1, 'J', ], 'J1', ], [ [ 10, 20, 'J', ], 'J20', ], [ [ 35, 1, 'AI', ], 'AI1', ], [ [ 35, 2012, 'AI', ], 'AI2012', ], [ [ 2, 3, 'B', ], 'B3', ], [ [ 2, 3, 'B', ], '$B3', ], [ [ 2, 3, 'B', ], 'B$3', ], [ [ 2, 3, 'B', ], '$B$3', ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/R1C1ConversionToA1Absolute.php
tests/data/Cell/R1C1ConversionToA1Absolute.php
<?php declare(strict_types=1); return [ ['A1', 'R1C1'], ['B2', 'R2C2'], ['L5', 'R5C12'], ['Z1024', 'R1024C26'], ['AA2048', 'R2048C27'], ['AZ4096', 'R4096C52'], ['BA8192', 'R8192C53'], ['IV65535', 'R65535C256'], ['K1', 'RC11'], ['A16', 'R16C'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/A1ConversionToR1C1Absolute.php
tests/data/Cell/A1ConversionToR1C1Absolute.php
<?php declare(strict_types=1); return [ ['R1C1', 'A1'], ['R1C1', '$A$1'], ['R1C1', '$A1'], ['R1C1', 'A$1'], ['R2C2', 'B2'], ['R5C12', 'L5'], ['R1024C26', 'Z1024'], ['R2048C27', 'AA2048'], ['R4096C52', 'AZ4096'], ['R8192C53', 'BA8192'], ['R65535C256', 'IV65535'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/R1C1ConversionToA1Exception.php
tests/data/Cell/R1C1ConversionToA1Exception.php
<?php declare(strict_types=1); return [ ['RICE'], ['R[-1]C'], ['RC[-1]'], ['R-1C'], ['RC-1'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/ConvertFormulaToA1FromR1C1Absolute.php
tests/data/Cell/ConvertFormulaToA1FromR1C1Absolute.php
<?php declare(strict_types=1); return [ 'Basic addition' => ['=D3+F7+G4+C6+5', '=R3C4+R7C6+R4C7+R6C3+5'], 'Basic subtraction' => ['=D3-F7-G4-C6-5', '=R3C4-R7C6-R4C7-R6C3-5'], 'Basic multiplication' => ['=D3*F7*G4*C6*5', '=R3C4*R7C6*R4C7*R6C3*5'], 'Basic division' => ['=D3/F7/G4/C6/5', '=R3C4/R7C6/R4C7/R6C3/5'], 'Simple formula' => ['=SUM(E1:E5)', '=SUM(R1C5:R5C5)'], 'Formula with range and cell' => ['=SUM(E1:E5, D5)', '=SUM(R1C5:R5C5, R5C4)'], 'Formula arithmetic' => ['=SUM(E1:E5, D5)-C5', '=SUM(R1C5:R5C5, R5C4)-R5C3'], 'Formula with comparison' => ['=IF(E1>E2, E3, E4)', '=IF(R1C5>R2C5, R3C5, R4C5)'], 'String literal' => ['=CONCAT("Result of formula expression =R3C3+R4C3 is: ", C3+C4)', '=CONCAT("Result of formula expression =R3C3+R4C3 is: ", R3C3+R4C3)'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/A1ConversionToR1C1Relative.php
tests/data/Cell/A1ConversionToR1C1Relative.php
<?php declare(strict_types=1); return [ ['R[2]C[2]', 'O18', 16, 13], ['R18C15', '$O$18', 16, 13], ['R[-2]C[2]', 'O14', 16, 13], ['R[-2]C15', '$O14', 16, 13], ['R[2]C[-2]', 'K18', 16, 13], ['R18C[-2]', 'K$18', 16, 13], ['R[-2]C[-2]', 'K14', 16, 13], ['RC[3]', 'P16', 16, 13], ['R16C[3]', 'P$16', 16, 13], ['RC[-3]', 'J16', 16, 13], ['RC10', '$J16', 16, 13], ['R[4]C', 'M20', 16, 13], ['R[4]C13', '$M20', 16, 13], ['R[-4]C', 'M12', 16, 13], ['R12C', 'M$12', 16, 13], ['RC', 'E5', 5, 5], ['R5C5', '$E$5', 5, 5], ['R5C', 'E5', null, 5], ['R5C5', '$E5', null, 5], ['R5C', 'E$5', null, 5], ['RC5', 'E5', 5, null], ['RC5', '$E5', 5, null], ['R5C5', 'E$5', 5, null], ['R5C[2]', 'E5', null, 3], ['R5C5', '$E5', null, 3], ['R5C[2]', 'E$5', null, 3], ['R[2]C5', 'E5', 3, null], ['R5C5', '$E$5', 3, null], ['R5C[-2]', 'E5', null, 7], ['R[-2]C5', 'E5', 7, null], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/CoordinateIsInsideRangeException.php
tests/data/Cell/CoordinateIsInsideRangeException.php
<?php declare(strict_types=1); return [ ['First argument needs to be a range', 'invalidRange', 'B4'], ['Second argument needs to be a single coordinate', 'A1:E20', 'invalidCoordinate'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/SetValueExplicitException.php
tests/data/Cell/SetValueExplicitException.php
<?php declare(strict_types=1); use PhpOffice\PhpSpreadsheet\Cell\DataType; return [ 'invalid numeric' => ['XYZ', DataType::TYPE_NUMERIC, 'Invalid numeric value'], 'invalid array' => [[], DataType::TYPE_STRING, 'Unable to convert to string'], 'invalid unstringable object' => [new DateTime(), DataType::TYPE_INLINE, 'Unable to convert to string'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Cell/A1ConversionToR1C1Exception.php
tests/data/Cell/A1ConversionToR1C1Exception.php
<?php declare(strict_types=1); return [ ['A11Y'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/CodePage.php
tests/data/Shared/CodePage.php
<?php declare(strict_types=1); return [ // ANSI Latin I (BIFF4-BIFF7) [ 'CP1252', 0, ], // ASCII [ 'ASCII', 367, ], // OEM US [ 'CP437', 437, ], // OEM Greek [ 'CP737', 737, ], // OEM Baltic [ 'CP775', 775, ], // OEM Latin I [ 'CP850', 850, ], // OEM Latin II (Central European) [ 'CP852', 852, ], // OEM Cyrillic [ 'CP855', 855, ], // OEM Turkish [ 'CP857', 857, ], // OEM Multilingual Latin I with Euro [ 'CP858', 858, ], // OEM Portugese [ 'CP860', 860, ], // OEM Icelandic [ 'CP861', 861, ], // OEM Hebrew [ 'CP862', 862, ], // OEM Canadian (French) [ 'CP863', 863, ], // OEM Arabic [ 'CP864', 864, ], // OEM Nordic [ 'CP865', 865, ], // OEM Cyrillic (Russian) [ 'CP866', 866, ], // OEM Greek (Modern) [ 'CP869', 869, ], // ANSI Thai [ 'CP874', 874, ], // ANSI Japanese Shift-JIS [ 'CP932', 932, ], // ANSI Chinese Simplified GBK [ 'CP936', 936, ], // ANSI Korean (Wansung) [ 'CP949', 949, ], // ANSI Chinese Traditional BIG5 [ 'CP950', 950, ], // UTF-16 (BIFF8) [ 'UTF-16LE', 1200, ], // ANSI Latin II (Central European) [ 'CP1250', 1250, ], // ANSI Cyrillic [ 'CP1251', 1251, ], // ANSI Latin I (BIFF4-BIFF7) [ 'CP1252', 1252, ], // ANSI Greek [ 'CP1253', 1253, ], // ANSI Turkish [ 'CP1254', 1254, ], // ANSI Hebrew [ 'CP1255', 1255, ], // ANSI Arabic [ 'CP1256', 1256, ], // ANSI Baltic [ 'CP1257', 1257, ], // ANSI Vietnamese [ 'CP1258', 1258, ], // ANSI Korean (Johab) [ 'CP1361', 1361, ], // Apple Roman [ 'MAC', 10000, ], // Macintosh Japanese [ 'CP932', 10001, ], // Macintosh Chinese Traditional [ 'CP950', 10002, ], // Macintosh Korean [ 'CP1361', 10003, ], // Apple Arabic [ 'MACARABIC', 10004, ], // Apple Hebrew [ 'MACHEBREW', 10005, ], // Macintosh Greek [ 'MACGREEK', 10006, ], // Macintosh Cyrillic [ 'MACCYRILLIC', 10007, ], // Macintosh - Simplified Chinese (GB 2312) [ 'CP936', 10008, ], // Macintosh Romania [ 'MACROMANIA', 10010, ], // Macintosh Ukraine [ 'MACUKRAINE', 10017, ], // Macintosh Thai [ 'MACTHAI', 10021, ], // Macintosh Central Europe [ ['MACCENTRALEUROPE', 'MAC-CENTRALEUROPE'], 10029, ], // Macintosh Icelandic [ 'MACICELAND', 10079, ], // Macintosh Turkish [ 'MACTURKISH', 10081, ], // Macintosh Croatian [ 'MACCROATIAN', 10082, ], // UTF-16 (BIFF8) grandfathers erroneous libraries [ 'UTF-16LE', 21010, ], // Apple Roman [ 'MAC', 32768, ], // Unicode (UTF-7) [ 'UTF-7', 65000, ], // Unicode (UTF-8) [ 'UTF-8', 65001, ], // invalid [ 'exception', 99999, ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/InchSizeToPixels.php
tests/data/Shared/InchSizeToPixels.php
<?php declare(strict_types=1); return [ [ 9.5999999999999996, 0.10000000000000001, ], [ 19.199999999999999, 0.20000000000000001, ], [ 48.0, 0.5, ], [ 96.0, 1.0, ], [ 192.0, 2.0, ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/PasswordHashes.php
tests/data/Shared/PasswordHashes.php
<?php declare(strict_types=1); return [ [ 'BCDE', 'PhpSpreadsheet', ], [ '877D', 'Mark Baker', ], [ 'C0EA', '!+&=()~§±æþ', ], [ 'C07E', '秘密口令', ], [ '99E8', 'leyndarmál lykilorð', ], [ 'CE4B', '', ], [ 'O6EXRLpLEDNJDL/AzYtnnA4O4bY=', '', 'SHA-1', ], [ 'GYvlIMljDI1Czc4jfWrGaxU5pxl9n5Og0KUzyAfYxwk=', 'PhpSpreadsheet', 'SHA-256', 'Php_salt', 1000, ], [ 'sSHdxQv9qgpkr4LDT0bYQxM9hOQJFRhJ4D752/NHQtDDR1EVy67NCEW9cPd6oWvCoBGd96MqKpuma1A7pN1nEA==', 'Mark Baker', 'SHA-512', 'Mark_salt', 10000, ], [ 'r9KVLLCKIYOILvE2rcby+g==', '!+&=()~§±æþ', 'MD5', 'Symbols_salt', 100000, ], // Additional tests suggested by Issue #1897 ['DCDF', 'ABCDEFGHIJKLMNOPQRSTUVW'], ['ECD1', 'ABCDEFGHIJKLMNOPQRSTUVWX'], ['88D2', 'ABCDEFGHIJKLMNOPQRSTUVWXY'], 'password too long' => ['exception', str_repeat('x', 256)], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/CentimeterSizeToPixels.php
tests/data/Shared/CentimeterSizeToPixels.php
<?php declare(strict_types=1); return [ [ 3.7795275590999999, 0.10000000000000001, ], [ 7.5590551181999999, 0.20000000000000001, ], [ 18.8976377955, 0.5, ], [ 37.795275590999999, 1.0, ], [ 75.590551181999999, 2.0, ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/FontSizeToPixels.php
tests/data/Shared/FontSizeToPixels.php
<?php declare(strict_types=1); return [ [ 8, 6, ], [ 9, 7, ], [ 10, 8, ], [ 12, 9, ], [ 13, 10, ], [ 14, 11, ], [ 16, 12, ], [ 18, 14, ], [ 21, 16, ], [ 24, 18, ], [ 26, 20, ], [ 29, 22, ], [ 32, 24, ], [ 48, 36, ], [ 64, 48, ], [ 80, 60, ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/Date/TimestampToExcel1900.php
tests/data/Shared/Date/TimestampToExcel1900.php
<?php declare(strict_types=1); // Unix TimeStamp Result Comments return [ // PHP 32-bit Earliest Date 14-Dec-1901 [ 714, -2147472000, ], // 31-Dec-1903 [ 1461, -2082931200, ], // Excel 1904 Calendar Base Date 01-Jan-1904 [ 1462, -2082844800, ], // 02-Jan-1904 [ 1463, -2082758400, ], // 19-Dec-1960 [ 22269, -285120000, ], // PHP Base Date 01-Jan-1970 [ 25569, 0, ], // 07-Dec-1982 [ 30292, 408067200, ], // 12-Jun-2008 [ 39611, 1213228800, ], // PHP 32-bit Latest Date 19-Jan-2038 [ 50424, 2147472000, ], // 18-May-1903 13:37:46 [ 1234.56789, -2102494934, ], // 18-Oct-1933 16:17:37 [ 12345.6789, -1142494943, ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/Date/ExcelToTimestamp1904.php
tests/data/Shared/Date/ExcelToTimestamp1904.php
<?php declare(strict_types=1); // Excel DateTimeStamp Result Comments return [ [ -1956528000, 1462, ], [ -1956441600, 1463, ], [ -158803200, 22269, ], [ 126316800, 25569, ], [ 534384000, 30292, ], [ 1339545600, 39611, ], // 06:00:00 [ gmmktime(6, 0, 0, 1, 1, 1904), // 32-bit safe - no Y2038 problem 0.25, ], // 08:00.00 [ gmmktime(8, 0, 0, 1, 1, 1904), // 32-bit safe - no Y2038 problem 0.3333333333333333333, ], // 13:02:13 [ gmmktime(13, 2, 13, 1, 1, 1904), // 32-bit safe - no Y2038 problem 0.54321, ], // 29-Apr-2038 00:00:00 beyond PHP 32-bit Latest Date [ 2156112000, 49062, ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/Date/ExcelToTimestamp1900.php
tests/data/Shared/Date/ExcelToTimestamp1900.php
<?php declare(strict_types=1); // Excel DateTimeStamp Result Comments return [ // PHP 32-bit Earliest Date 14-Dec-1901 [ -2147472000, 714, ], // 31-Dec-1903 [ -2082931200, 1461, ], // Excel 1904 Calendar Base Date 01-Jan-1904 [ -2082844800, 1462, ], // 02-Jan-1904 [ -2082758400, 1463, ], // 19-Dec-1960 [ -285120000, 22269, ], // PHP Base Date 01-Jan-1970 [ 0, 25569, ], // 07-Dec-1982 [ 408067200, 30292, ], // 12-Jun-2008 [ 1213228800, 39611, ], // PHP 32-bit Latest Date 9-Jan-2038 [ 2147472000, 50424, ], // 18-May-1903 13:37:46 [ -2102494934, 1234.56789, ], // 18-Oct-1933 16:17:37 [ -1142494943, 12345.6789, ], // 12:00:00 [ 43200, 0.5, ], // 18:00.00 [ 64800, 0.75, ], // 02:57:46 [ 10666, 0.12345, ], // 29-Apr-2038 00:00:00 beyond PHP 32-bit Latest Date [ 2156112000, 50524, ], [-2147483648, -2147483648 / 86400], // Okay on 64- and 32-bit systems [-2147483649, -2147483649 / 86400], // Skipped test on 32-bit ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/Date/DateTimeToExcel.php
tests/data/Shared/Date/DateTimeToExcel.php
<?php declare(strict_types=1); // DateTime object Result Comments return [ // Excel 1900 base calendar date [ 1.0, new DateTime('1900-01-01'), ], // This and next test show gap for the mythical [ 59.0, new DateTime('1900-02-28'), ], // MS Excel 1900 Leap Year [ 61.0, new DateTime('1900-03-01'), ], // Unix Timestamp 32-bit Earliest Date [ 714.0, new DateTime('1901-12-14'), ], [ 1461.0, new DateTime('1903-12-31'), ], // Excel 1904 Calendar Base Date [ 1462.0, new DateTime('1904-01-01'), ], [ 1463.0, new DateTime('1904-01-02'), ], [ 22269.0, new DateTime('1960-12-19'), ], // Unix Timestamp Base Date [ 25569.0, new DateTime('1970-01-01'), ], [ 30292.0, new DateTime('1982-12-07'), ], [ 39611.0, new DateTime('2008-06-12'), ], // Unix Timestamp 32-bit Latest Date [ 50424.0, new DateTime('2038-01-19'), ], [ 1234.56789, new DateTime('1903-05-18 13:37:46'), ], [ 12345.6789, new DateTime('1933-10-18 16:17:37'), ], [ 73050.0, new DateTime('2099-12-31'), ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/Date/FormattedPHPToExcel1900.php
tests/data/Shared/Date/FormattedPHPToExcel1900.php
<?php declare(strict_types=1); // Year Month Day Hours Minutes Seconds Result Comments return [ // PHP 32-bit Earliest Date 14-Dec-1901 [ 714, 1901, 12, 14, ], // 31-Dec-1903 [ 1461, 1903, 12, 31, ], // Excel 1904 Calendar Base Date 01-Jan-1904 [ 1462, 1904, 1, 1, ], // 02-Jan-1904 [ 1463, 1904, 1, 2, ], // 19-Dec-1960 [ 22269, 1960, 12, 19, ], // PHP Base Date 01-Jan-1970 [ 25569, 1970, 1, 1, ], // 07-Dec-1982 [ 30292, 1982, 12, 7, ], // 12-Jun-2008 [ 39611, 2008, 6, 12, ], // PHP 32-bit Latest Date 19-Jan-2038 [ 50424, 2038, 1, 19, ], // 18-May-1903 13:37:46 [ 1234.56789, 1903, 5, 18, 13, 37, 46, ], // 18-Oct-1933 16:17:37 [ 12345.6789, 1933, 10, 18, 16, 17, 37, ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/Date/TimestampToExcel1904.php
tests/data/Shared/Date/TimestampToExcel1904.php
<?php declare(strict_types=1); // Excel DateTimeStamp Result return [ [ 1462, -1956528000, ], [ 1463, -1956441600, ], [ 22269, -158803200, ], [ 25569, 126316800, ], [ 30292, 534384000, ], [ 39611, 1339545600, ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/Date/ExcelToTimestamp1900Timezone.php
tests/data/Shared/Date/ExcelToTimestamp1900Timezone.php
<?php declare(strict_types=1); // Excel DateTimeStamp Timezone Result Comments return [ // 19-Dec-1960 00:00:00 EST => 19-Dec-1960 05:00:00 UTC [ -285102000, 22269, 'America/New_York', ], // 01-Jan-1970 00:00:00 EST => 01-Jan-1970 05:00:00 UTC PHP Base Date [ 18000, 25569, 'America/New_York', ], // 07-Dec-1982 00:00:00 EST => 07-Dec-1982 05:00:00 UTC [ 408085200, 30292, 'America/New_York', ], // 12-Jun-2008 00:00:00 EDT => 12-Jun-2008 04:00:00 UTC [ 1213243200, 39611, 'America/New_York', ], // 19-Jan-2038 00:00:00 EST => 19-Jan-2038 05:00:00 UTC PHP 32-bit Latest Date [ 2147490000, 50424, 'America/New_York', ], // 05-Mar-1961 13:37:46 EST => 05-Mar-1961 18:37:46 UTC [ -278486534, 22345.56789, 'America/New_York', ], // 05-Mar-1961 16:17:37 EST => 05-Mar-1961 21:17:37 UTC [ -278476943, 22345.6789, 'America/New_York', ], // 12:00:00 EST => 17:00:00 UTC [ 61200, 0.5, 'America/New_York', ], // 18:00.00 EST => 23:00:00 UTC [ 82800, 0.75, 'America/New_York', ], // 02:57:46 EST => 07:57:46 UTC [ 28666, 0.12345, 'America/New_York', ], // 02-Nov-2012 00:00:00 EDT => 02-Nov-2012 04:00:00 UTC [ 1351828800, 41215, 'America/New_York', ], // 19-Dec-1960 00:00:00 NZST => 18-Dec-1960 12:00:00 UTC [ -285163200, 22269, 'Pacific/Auckland', ], // 01-Jan-1970 00:00:00 NZST => 31-Dec-1969 12:00:00 UTC PHP Base Date [ -43200, 25569, 'Pacific/Auckland', ], // 07-Dec-1982 00:00:00 NZDT => 06-Dec-1982 11:00:00 UTC [ 408020400, 30292, 'Pacific/Auckland', ], // 12-Jun-2008 00:00:00 NZST => 11-Jun-2008 12:00:00 UTC [ 1213185600, 39611, 'Pacific/Auckland', ], // 18-Jan-2038 12:00:00 NZDT => 17-Jan-2038 23:00:00 UTC PHP 32-bit Latest Date [ 2147382000, 50423.5, 'Pacific/Auckland', ], // 05-Mar-1961 13:37:46 NZST => 05-Mar-1961 01:37:46 UTC [ -278547734, 22345.56789, 'Pacific/Auckland', ], // 05-Mar-1961 16:17:37 NZST => 05-Mar-1961 04:17:37 UTC [ -278538143, 22345.6789, 'Pacific/Auckland', ], // 12:00:00 NZST => 00:00:00 UTC [ 0, 0.5, 'Pacific/Auckland', ], // 18:00.00 NZST => 06:00:00 UTC [ 21600, 0.75, 'Pacific/Auckland', ], // 02:57:46 NZST => 14:57:46 UTC [ -32534, 0.12345, 'Pacific/Auckland', ], // 02-Nov-2012 00:00:00 NZDT => 01-Nov-2012 11:00:00 UTC [ 1351767600, 41215, 'Pacific/Auckland', ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/Date/FormatCodes.php
tests/data/Shared/Date/FormatCodes.php
<?php declare(strict_types=1); // Excel Format Code Result return [ [ false, 'General', ], [ false, '@', ], [ false, '0', ], [ false, '0.00', ], [ false, '#,##0.00', ], [ false, '#,##0.00_-', ], [ false, '0%', ], [ false, '0.00%', ], [ true, 'yyyy-mm-dd', ], [ true, 'yy-mm-dd', ], [ true, 'dd/mm/yy', ], [ true, 'd/m/y', ], [ true, 'd-m-y', ], [ true, 'd-m', ], [ true, 'm-y', ], [ true, 'mm-dd-yy', ], [ true, 'd-mmm-yy', ], [ true, 'd-mmm', ], [ true, 'mmm-yy', ], [ true, 'm/d/yy h:mm', ], [ true, 'd/m/y h:mm', ], [ true, 'h:mm AM/PM', ], [ true, 'h:mm:ss AM/PM', ], [ true, 'h:mm', ], [ true, 'h:mm:ss', ], [ true, 'mm:ss', ], [ true, 'h:mm:ss', ], [ true, 'i:s.S', ], [ true, 'h:mm:ss;@', ], [ true, 'yy/mm/dd;@', ], [ false, '"$" #,##0.00_-', ], [ false, '$#,##0_-', ], [ false, '[$EUR ]#,##0.00_-', ], [ false, '_[$EUR ]#,##0.00_-', ], [ false, '[Green]#,##0.00;[Red]#,##0.00_-', ], [ false, '#,##0.00 "dollars"', ], [ true, '"date " y-m-d', ], [ false, '\C\H\-00000', ], [ false, '\D-00000', ], [true, '[$-F800]'], [true, 'hello[$-F400]goodbye'], [false, '[$-F401]'], [true, '[$-x-sysdate]'], [true, '[$-x-systime]'], [false, '[$-x-systim]'], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/Trend/ExponentialBestFit.php
tests/data/Shared/Trend/ExponentialBestFit.php
<?php declare(strict_types=1); return [ [ 'expectedSlope' => [0.8, 0.813512072856517], 'expectedIntersect' => [20.7, 20.671878197177865], 'expectedGoodnessOfFit' => [0.904868, 0.9048681877346413], 'expectedEquation' => 'Y = 20.67 * 0.81^X', 'yValues' => [3, 10, 3, 6, 8, 12, 1, 4, 9, 14], 'xValues' => [8, 2, 11, 6, 5, 4, 12, 9, 6, 1], ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/tests/data/Shared/Trend/LinearBestFit.php
tests/data/Shared/Trend/LinearBestFit.php
<?php declare(strict_types=1); return [ [ 'expectedSlope' => [-1.1, -1.1064189189190], 'expectedIntersect' => [14.1, 14.081081081081], 'expectedGoodnessOfFit' => [0.873138, 0.8731378215564962], 'expectedEquation' => 'Y = 14.08 + -1.11 * X', 'yValues' => [3, 10, 3, 6, 8, 12, 1, 4, 9, 14], 'xValues' => [8, 2, 11, 6, 5, 4, 12, 9, 6, 1], 'xForY' => 12.72671756, ], [ 'expectedSlope' => [1.0, 1.0], 'expectedIntersect' => [-2.0, -2.0], 'expectedGoodnessOfFit' => [1.0, 1.0], 'expectedEquation' => 'Y = -2 + 1 * X', 'yValues' => [1, 2, 3, 4, 5], 'xValues' => [3, 4, 5, 6, 7], 'xForY' => 2.0, ], ];
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Bootstrap.php
samples/Bootstrap.php
<?php /** * Bootstrap for PhpSpreadsheet classes. */ // This sucks, but we have to try to find the composer autoloader $paths = [ __DIR__ . '/../vendor/autoload.php', // In case PhpSpreadsheet is cloned directly __DIR__ . '/../../../autoload.php', // In case PhpSpreadsheet is a composer dependency. ]; foreach ($paths as $path) { if (file_exists($path)) { require_once $path; return; } } throw new Exception('Composer autoloader could not be found. Install dependencies with `composer install` and try again.');
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/index.php
samples/index.php
<?php require_once __DIR__ . '/Header.php'; $requirements = [ 'PHP 8.1' => version_compare(PHP_VERSION, '8.1', '>='), 'PHP extension XML' => extension_loaded('xml'), 'PHP extension xmlwriter' => extension_loaded('xmlwriter'), 'PHP extension mbstring' => extension_loaded('mbstring'), 'PHP extension ZipArchive' => extension_loaded('zip'), 'PHP extension GD (optional)' => extension_loaded('gd'), 'PHP extension dom (optional)' => extension_loaded('dom'), ]; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ if (!$helper->isCli()) { ?> <div class="jumbotron"> <p>Welcome to PHPSpreadsheet, a library written in pure PHP and providing a set of classes that allow you to read from and to write to different spreadsheet file formats, like Excel and LibreOffice Calc.</p> <p>&nbsp;</p> <p> <a class="btn btn-lg btn-primary" href="https://github.com/PHPOffice/PHPSpreadsheet" role="button"><i class="fa fa-github fa-lg" title="GitHub"></i> Fork us on Github!</a> <a class="btn btn-lg btn-primary" href="https://phpspreadsheet.readthedocs.io" role="button"><i class="fa fa-book fa-lg" title="Docs"></i> Read the Docs</a> </p> </div> <?php echo '<h3>Requirement check</h3>'; echo '<ul>'; foreach ($requirements as $label => $result) { $status = $result ? 'passed' : 'failed'; echo "<li>{$label} ... <span class='{$status}'>{$status}</span></li>"; } echo '</ul>'; } else { echo 'Requirement check:' . PHP_EOL; foreach ($requirements as $label => $result) { $status = $result ? '32m passed' : '31m failed'; echo "{$label} ... \033[{$status}\033[0m" . PHP_EOL; } }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/download.php
samples/download.php
<?php require_once __DIR__ . '/Bootstrap.php'; use PhpOffice\PhpSpreadsheet\Helper\Downloader; use PhpOffice\PhpSpreadsheet\Helper\Sample; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; $filename = basename(StringHelper::convertToString($_GET['name'] ?? '')); $filetype = StringHelper::convertToString($_GET['type'] ?? ''); try { $downloader = new Downloader((new Sample())->getTemporaryFolder(), $filename, $filetype); $downloader->download(); } catch (Exception $e) { exit($e->getMessage()); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Header.php
samples/Header.php
<?php /** * Header file. */ use PhpOffice\PhpSpreadsheet\Helper\Sample; error_reporting(E_ALL); require_once __DIR__ . '/Bootstrap.php'; $helper = new Sample(); // Return to the caller script when runs by CLI if ($helper->isCli()) { return; } ?> <html> <head> <title><?php echo $helper->getPageTitle(); ?></title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css"/> <link rel="stylesheet" href="/bootstrap/css/font-awesome.min.css"/> <link rel="stylesheet" href="/bootstrap/css/phpspreadsheet.css"/> <script src="/bootstrap/js/jquery.min.js"></script> <script src="/bootstrap/js/bootstrap.min.js"></script> <style> body { padding-top: 200px; } </style> </head> <body> <div class="container"> <div class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="/">PHPSpreadsheet</a> </div> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"><?php foreach ($helper->getSamples() as $category => $files) { ?><li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo $category ?> <strong class="caret"></strong> </a> <ul class="dropdown-menu"><?php foreach ($files as $name => $file) { if ( !in_array( $file, [ 'Chart/35_Chart_render.php', 'Chart/35_Chart_render33.php', ], true ) ) { echo '<li><a href="/' . $file . '">' . $name . '</a></li>'; } } ?></ul> </li> <?php } ?> </ul> <ul class="nav navbar-nav navbar-right"> <li> <a href="https://github.com/PHPOffice/PHPSpreadsheet"> <i class="fa fa-github fa-lg" title="GitHub"></i> &nbsp; </a> </li> <li> <a href="https://phpspreadsheet.readthedocs.io"> <i class="fa fa-book fa-lg" title="Docs"></i> &nbsp; </a> </li> </ul> </div> </div> </div> <?php echo $helper->getPageHeading();
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/ComplexNumbers1/COMPLEX.php
samples/ComplexNumbers1/COMPLEX.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $category = 'Engineering'; $functionName = 'COMPLEX'; $description = 'Converts real and imaginary coefficients into a complex number of the form x + yi or x + yj'; $helper->titles($category, $functionName, $description); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); // Add some data $testData = [ [3, 4], [3, 4, '"j"'], [3.5, 4.75], [0, 1], [1, 0], [0, -1], [0, 2], [2, 0], ]; $testDataCount = count($testData); for ($row = 1; $row <= $testDataCount; ++$row) { $worksheet->setCellValue('A' . $row, '=COMPLEX(' . implode(',', $testData[$row - 1]) . ')'); } for ($row = 1; $row <= $testDataCount; ++$row) { $helper->log( "(A$row): Formula " . $worksheet->getCell('A' . $row)->getValueString() . ' result is ' . $worksheet->getCell('A' . $row)->getCalculatedValueString() ); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/ComplexNumbers1/IMARGUMENT.php
samples/ComplexNumbers1/IMARGUMENT.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $category = 'Engineering'; $functionName = 'IMARGUMENT'; $description = 'Returns the argument Theta, an angle expressed in radians'; $helper->titles($category, $functionName, $description); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); // Add some data $testData = [ ['3+4i'], ['5-12i'], ['3.25+7.5i'], ['3.25-12.5i'], ['-3.25+7.5i'], ['-3.25-7.5i'], ['0-j'], ['0-2.5j'], ['0+j'], ['0+1.25j'], [4], [-2.5], ]; $testDataCount = count($testData); $worksheet->fromArray($testData, null, 'A1', true); for ($row = 1; $row <= $testDataCount; ++$row) { $worksheet->setCellValue('B' . $row, '=IMARGUMENT(A' . $row . ')'); } // Test the formulae for ($row = 1; $row <= $testDataCount; ++$row) { $helper->log( "(E$row): The Theta Argument of " . $worksheet->getCell('A' . $row)->getValueString() . ' is ' . $worksheet->getCell('B' . $row)->getCalculatedValueString() . ' radians' ); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/ComplexNumbers1/IMREAL.php
samples/ComplexNumbers1/IMREAL.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $category = 'Engineering'; $functionName = 'IMREAL'; $description = 'Returns the real coefficient of a complex number in x + yi or x + yj text format'; $helper->titles($category, $functionName, $description); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); // Add some data $testData = [ ['3+4i'], ['5-12i'], ['3.25+7.5i'], ['3.25-12.5i'], ['-3.25+7.5i'], ['-3.25-7.5i'], ['0-j'], ['0-2.5j'], ['0+j'], ['0+1.25j'], [4], [-2.5], ]; $testDataCount = count($testData); $worksheet->fromArray($testData, null, 'A1', true); for ($row = 1; $row <= $testDataCount; ++$row) { $worksheet->setCellValue('B' . $row, '=IMREAL(A' . $row . ')'); } // Test the formulae for ($row = 1; $row <= $testDataCount; ++$row) { $helper->log( "(E$row): The real component of " . $worksheet->getCell('A' . $row)->getValueString() . ' is ' . $worksheet->getCell('B' . $row)->getCalculatedValueString() ); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/ComplexNumbers1/IMAGINARY.php
samples/ComplexNumbers1/IMAGINARY.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $category = 'Engineering'; $functionName = 'IMAGINARY'; $description = 'Returns the imaginary coefficient of a complex number in x + yi or x + yj text format'; $helper->titles($category, $functionName, $description); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); // Add some data $testData = [ ['3+4i'], ['5-12i'], ['3.25+7.5i'], ['3.25-12.5i'], ['-3.25+7.5i'], ['-3.25-7.5i'], ['0-j'], ['0-2.5j'], ['0+j'], ['0+1.25j'], [4], [-2.5], ]; $testDataCount = count($testData); $worksheet->fromArray($testData, null, 'A1', true); for ($row = 1; $row <= $testDataCount; ++$row) { $worksheet->setCellValue('B' . $row, '=IMAGINARY(A' . $row . ')'); } // Test the formulae for ($row = 1; $row <= $testDataCount; ++$row) { $helper->log( "(E$row): The imaginary component of " . $worksheet->getCell('A' . $row)->getValueString() . ' is ' . $worksheet->getCell('B' . $row)->getCalculatedValueString() ); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/ComplexNumbers1/IMCONJUGATE.php
samples/ComplexNumbers1/IMCONJUGATE.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $category = 'Engineering'; $functionName = 'IMCONJUGATE'; $description = 'Returns the complex conjugate of a complex number in x + yi or x + yj text format'; $helper->titles($category, $functionName, $description); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); // Add some data $testData = [ ['3+4i'], ['5-12i'], ['3.25+7.5i'], ['3.25-12.5i'], ['-3.25+7.5i'], ['-3.25-7.5i'], ['0-j'], ['0-2.5j'], ['0+j'], ['0+1.25j'], [4], [-2.5], ]; $testDataCount = count($testData); $worksheet->fromArray($testData, null, 'A1', true); for ($row = 1; $row <= $testDataCount; ++$row) { $worksheet->setCellValue('B' . $row, '=IMCONJUGATE(A' . $row . ')'); } // Test the formulae for ($row = 1; $row <= $testDataCount; ++$row) { $helper->log( "(E$row): The Conjugate value of " . $worksheet->getCell('A' . $row)->getValueString() . ' is ' . $worksheet->getCell('B' . $row)->getCalculatedValueString() ); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/ComplexNumbers1/IMABS.php
samples/ComplexNumbers1/IMABS.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $category = 'Engineering'; $functionName = 'IMABS'; $description = 'Returns the absolute value (modulus) of a complex number in x + yi or x + yj text format'; $helper->titles($category, $functionName, $description); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); // Add some data $testData = [ ['3+4i'], ['5-12i'], ['3.25+7.5i'], ['3.25-12.5i'], ['-3.25+7.5i'], ['-3.25-7.5i'], ['0-j'], ['0-2.5j'], ['0+j'], ['0+1.25j'], [4], [-2.5], ]; $testDataCount = count($testData); $worksheet->fromArray($testData, null, 'A1', true); for ($row = 1; $row <= $testDataCount; ++$row) { $worksheet->setCellValue('B' . $row, '=IMABS(A' . $row . ')'); } // Test the formulae for ($row = 1; $row <= $testDataCount; ++$row) { $helper->log( "(E$row): The absolute value of " . $worksheet->getCell('A' . $row)->getValueString() . ' is ' . $worksheet->getCell('B' . $row)->getCalculatedValueString() ); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Bitwise/BITAND.php
samples/Bitwise/BITAND.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $category = 'Engineering'; $functionName = 'BITAND'; $description = "Returns a bitwise 'AND' of two numbers"; $helper->titles($category, $functionName, $description); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); // Add some data $testData = [ [1, 5], [3, 5], [1, 6], [9, 6], [13, 25], [23, 10], ]; $testDataCount = count($testData); $worksheet->fromArray($testData, null, 'A1', true); for ($row = 1; $row <= $testDataCount; ++$row) { $worksheet->setCellValue('C' . $row, '=TEXT(DEC2BIN(A' . $row . '), "00000")'); $worksheet->setCellValue('D' . $row, '=TEXT(DEC2BIN(B' . $row . '), "00000")'); $worksheet->setCellValue('E' . $row, '=BITAND(A' . $row . ',B' . $row . ')'); $worksheet->setCellValue('F' . $row, '=TEXT(DEC2BIN(E' . $row . '), "00000")'); } // Test the formulae for ($row = 1; $row <= $testDataCount; ++$row) { $helper->log( "(E$row): Bitwise AND of " . $worksheet->getCell('A' . $row)->getValueString() . ' (' . $worksheet->getCell('C' . $row)->getCalculatedValueString() . ') and ' . $worksheet->getCell('B' . $row)->getValueString() . '(' . $worksheet->getCell('D' . $row)->getCalculatedValueString() . ') is ' . $worksheet->getCell('E' . $row)->getCalculatedValueString() . ' (' . $worksheet->getCell('F' . $row)->getCalculatedValueString() . ')' ); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Bitwise/BITRSHIFT.php
samples/Bitwise/BITRSHIFT.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $category = 'Engineering'; $functionName = 'BITRSHIFT'; $description = 'Returns a number shifted right by the specified number of bits'; $helper->titles($category, $functionName, $description); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); // Add some data $testData = [ [9], [15], [26], ]; $testDataCount = count($testData); $worksheet->fromArray($testData, null, 'A1', true); for ($row = 1; $row <= $testDataCount; ++$row) { $worksheet->setCellValue('B' . $row, '=DEC2BIN(A' . $row . ')'); $worksheet->setCellValue('C' . $row, '=BITRSHIFT(A' . $row . ',1)'); $worksheet->setCellValue('D' . $row, '=DEC2BIN(C' . $row . ')'); $worksheet->setCellValue('E' . $row, '=BITRSHIFT(A' . $row . ',2)'); $worksheet->setCellValue('F' . $row, '=DEC2BIN(E' . $row . ')'); $worksheet->setCellValue('G' . $row, '=BITRSHIFT(A' . $row . ',3)'); $worksheet->setCellValue('H' . $row, '=DEC2BIN(G' . $row . ')'); } // Test the formulae for ($row = 1; $row <= $testDataCount; ++$row) { $helper->log( "(E$row): Bitwise Right Shift of " . $worksheet->getCell('A' . $row)->getValueString() . ' (' . $worksheet->getCell('B' . $row)->getCalculatedValueString() . ') by 1 bit is ' . $worksheet->getCell('C' . $row)->getCalculatedValueString() . ' (' . $worksheet->getCell('D' . $row)->getCalculatedValueString() . ')' ); $helper->log( "(E$row): Bitwise Right Shift of " . $worksheet->getCell('A' . $row)->getValueString() . ' (' . $worksheet->getCell('B' . $row)->getCalculatedValueString() . ') by 2 bits is ' . $worksheet->getCell('E' . $row)->getCalculatedValueString() . ' (' . $worksheet->getCell('F' . $row)->getCalculatedValueString() . ')' ); $helper->log( "(E$row): Bitwise Right Shift of " . $worksheet->getCell('A' . $row)->getValueString() . ' (' . $worksheet->getCell('B' . $row)->getCalculatedValueString() . ') by 3 bits is ' . $worksheet->getCell('G' . $row)->getCalculatedValueString() . ' (' . $worksheet->getCell('H' . $row)->getCalculatedValueString() . ')' ); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Bitwise/BITOR.php
samples/Bitwise/BITOR.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $category = 'Engineering'; $functionName = 'BITOR'; $description = "Returns a bitwise 'OR' of two numbers"; $helper->titles($category, $functionName, $description); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); // Add some data $testData = [ [1, 5], [3, 5], [1, 6], [9, 6], [13, 25], [23, 10], ]; $testDataCount = count($testData); $worksheet->fromArray($testData, null, 'A1', true); for ($row = 1; $row <= $testDataCount; ++$row) { $worksheet->setCellValue('C' . $row, '=TEXT(DEC2BIN(A' . $row . '), "00000")'); $worksheet->setCellValue('D' . $row, '=TEXT(DEC2BIN(B' . $row . '), "00000")'); $worksheet->setCellValue('E' . $row, '=BITOR(A' . $row . ',B' . $row . ')'); $worksheet->setCellValue('F' . $row, '=TEXT(DEC2BIN(E' . $row . '), "00000")'); } // Test the formulae for ($row = 1; $row <= $testDataCount; ++$row) { $helper->log( "(E$row): Bitwise OR of " . $worksheet->getCell('A' . $row)->getValueString() . ' (' . $worksheet->getCell('C' . $row)->getCalculatedValueString() . ') and ' . $worksheet->getCell('B' . $row)->getValueString() . '(' . $worksheet->getCell('D' . $row)->getCalculatedValueString() . ') is ' . $worksheet->getCell('E' . $row)->getCalculatedValueString() . ' (' . $worksheet->getCell('F' . $row)->getCalculatedValueString() . ')' ); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Bitwise/BITLSHIFT.php
samples/Bitwise/BITLSHIFT.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $category = 'Engineering'; $functionName = 'BITLSHIFT'; $description = 'Returns a number shifted left by the specified number of bits'; $helper->titles($category, $functionName, $description); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); // Add some data $testData = [ [1], [3], [9], [15], [26], ]; $testDataCount = count($testData); $worksheet->fromArray($testData, null, 'A1', true); for ($row = 1; $row <= $testDataCount; ++$row) { $worksheet->setCellValue('B' . $row, '=DEC2BIN(A' . $row . ')'); $worksheet->setCellValue('C' . $row, '=BITLSHIFT(A' . $row . ',1)'); $worksheet->setCellValue('D' . $row, '=DEC2BIN(C' . $row . ')'); $worksheet->setCellValue('E' . $row, '=BITLSHIFT(A' . $row . ',2)'); $worksheet->setCellValue('F' . $row, '=DEC2BIN(E' . $row . ')'); $worksheet->setCellValue('G' . $row, '=BITLSHIFT(A' . $row . ',3)'); $worksheet->setCellValue('H' . $row, '=DEC2BIN(G' . $row . ')'); } // Test the formulae for ($row = 1; $row <= $testDataCount; ++$row) { $helper->log( "(E$row): Bitwise Left Shift of " . $worksheet->getCell('A' . $row)->getValueString() . ' (' . $worksheet->getCell('B' . $row)->getCalculatedValueString() . ') by 1 bit is ' . $worksheet->getCell('C' . $row)->getCalculatedValueString() . ' (' . $worksheet->getCell('D' . $row)->getCalculatedValueString() . ')' ); $helper->log( "(E$row): Bitwise Left Shift of " . $worksheet->getCell('A' . $row)->getValueString() . ' (' . $worksheet->getCell('B' . $row)->getCalculatedValueString() . ') by 2 bits is ' . $worksheet->getCell('E' . $row)->getCalculatedValueString() . ' (' . $worksheet->getCell('F' . $row)->getCalculatedValueString() . ')' ); $helper->log( "(E$row): Bitwise Left Shift of " . $worksheet->getCell('A' . $row)->getValueString() . ' (' . $worksheet->getCell('B' . $row)->getCalculatedValueString() . ') by 3 bits is ' . $worksheet->getCell('G' . $row)->getCalculatedValueString() . ' (' . $worksheet->getCell('H' . $row)->getCalculatedValueString() . ')' ); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Bitwise/BITXOR.php
samples/Bitwise/BITXOR.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $category = 'Engineering'; $functionName = 'BITXOR'; $description = "Returns a bitwise 'XOR' of two numbers"; $helper->titles($category, $functionName, $description); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); // Add some data $testData = [ [1, 5], [3, 5], [1, 6], [9, 6], [13, 25], [23, 10], ]; $testDataCount = count($testData); $worksheet->fromArray($testData, null, 'A1', true); for ($row = 1; $row <= $testDataCount; ++$row) { $worksheet->setCellValue('C' . $row, '=TEXT(DEC2BIN(A' . $row . '), "00000")'); $worksheet->setCellValue('D' . $row, '=TEXT(DEC2BIN(B' . $row . '), "00000")'); $worksheet->setCellValue('E' . $row, '=BITXOR(A' . $row . ',B' . $row . ')'); $worksheet->setCellValue('F' . $row, '=TEXT(DEC2BIN(E' . $row . '), "00000")'); } // Test the formulae for ($row = 1; $row <= $testDataCount; ++$row) { $helper->log( "(E$row): Bitwise XOR of " . $worksheet->getCell('A' . $row)->getValueString() . ' (' . $worksheet->getCell('C' . $row)->getCalculatedValueString() . ') and ' . $worksheet->getCell('B' . $row)->getValueString() . '(' . $worksheet->getCell('D' . $row)->getCalculatedValueString() . ') is ' . $worksheet->getCell('E' . $row)->getCalculatedValueString() . ' (' . $worksheet->getCell('F' . $row)->getCalculatedValueString() . ')' ); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/LookupRef/SortExcel.php
samples/LookupRef/SortExcel.php
<?php namespace PhpOffice\PhpSpreadsheet\Calculation\LookupRef; use Exception; use PhpOffice\PhpSpreadsheet\Helper\Sample; use PhpOffice\PhpSpreadsheet\Helper\TextGridRightAlign; use Stringable; class SortExcel { public const ASCENDING = 1; public const DESCENDING = -1; private int $arrayCol; private int $ascending; private function cmp(mixed $rowA, mixed $rowB): int { $a = is_array($rowA) ? $rowA[$this->arrayCol] : $rowA; $b = is_array($rowB) ? $rowB[$this->arrayCol] : $rowB; if ($a instanceof Stringable) { $a = (string) $a; } if ($b instanceof Stringable) { $b = (string) $b; } if (is_array($a) || is_object($a) || is_resource($a) || is_array($b) || is_object($b) || is_resource($b)) { throw new Exception('Invalid datatype'); } // null sorts highest if ($a === null) { return ($b === null) ? 0 : $this->ascending; } if ($b === null) { return -$this->ascending; } // int|float sorts lowest $numericA = is_int($a) || is_float($a); $numericB = is_int($b) || is_float($b); if ($numericA && $numericB) { if ($a == $b) { return 0; } return ($a < $b) ? -$this->ascending : $this->ascending; } if ($numericA) { return -$this->ascending; } if ($numericB) { return $this->ascending; } // bool sorts higher than string if (is_bool($a)) { if (!is_bool($b)) { return $this->ascending; } if ($a) { return $b ? 0 : $this->ascending; } return $b ? -$this->ascending : 0; } if (is_bool($b)) { return -$this->ascending; } // special handling for numeric strings starting with - /** @var string $a */ $a2 = (string) preg_replace('/^-(\d)+$/', '$1', $a); /** @var string $b */ $b2 = (string) preg_replace('/^-(\d)+$/', '$1', $b); // strings sort case-insensitive return $this->ascending * strcasecmp($a2, $b2); } /** * @param mixed[] $array */ public function sortArray(array &$array, int $ascending = self::ASCENDING, int $arrayCol = 0): void { if ($ascending !== 1 && $ascending !== -1) { throw new Exception('ascending must be 1 or -1'); } $this->ascending = $ascending; $this->arrayCol = $arrayCol; usort($array, $this->cmp(...)); } } require __DIR__ . '/../Header.php'; /** @var Sample $helper */ $helper->log('Emulating how Excel sorts different DataTypes'); /** @param mixed[] $original */ function displaySorted(array $original, Sample $helper): void { $sorted = $original; $sortExcel = new SortExcel(); $sortExcel->sortArray($sorted); $outArray = [['Original', 'Sorted']]; $count = count($original); for ($i = 0; $i < $count; ++$i) { $outArray[] = [$original[$i], $sorted[$i]]; } $helper->displayGrid($outArray, TextGridRightAlign::floatOrInt); } $helper->log('First example'); $original = ['-3', '40', 'A', 'B', true, false, '+3', '1', '10', '2', '25', 1, 0, -1]; displaySorted($original, $helper); $helper->log('Second example'); $original = ['a', 'A', null, 'x', 'X', true, false, -3, 1]; displaySorted($original, $helper);
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/LookupRef/COLUMNS.php
samples/LookupRef/COLUMNS.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $helper->log('Returns the number of columns in an array or reference.'); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); $worksheet->getCell('A1')->setValue('=COLUMNS(C1:G4)'); $worksheet->getCell('A2')->setValue('=COLUMNS({1,2,3;4,5,6})'); $worksheet->getCell('A3')->setValue('=ROWS(C1:E4 D3:G5)'); $worksheet->getCell('A4')->setValue('=COLUMNS(1:1)'); for ($row = 1; $row <= 4; ++$row) { $cell = $worksheet->getCell("A{$row}"); $helper->log("A{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString()); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/LookupRef/SortExcelCols.php
samples/LookupRef/SortExcelCols.php
<?php namespace PhpOffice\PhpSpreadsheet\Calculation\LookupRef; use Exception; use PhpOffice\PhpSpreadsheet\Helper\Sample; use PhpOffice\PhpSpreadsheet\Helper\TextGridRightAlign; use Stringable; // this is the same class as in sortExcel class SortExcelCols { public const ASCENDING = 1; public const DESCENDING = -1; private int $arrayCol; private int $ascending; private function cmp(mixed $rowA, mixed $rowB): int { $a = is_array($rowA) ? $rowA[$this->arrayCol] : $rowA; $b = is_array($rowB) ? $rowB[$this->arrayCol] : $rowB; if ($a instanceof Stringable) { $a = (string) $a; } if ($b instanceof Stringable) { $b = (string) $b; } if (is_array($a) || is_object($a) || is_resource($a) || is_array($b) || is_object($b) || is_resource($b)) { throw new Exception('Invalid datatype'); } // null sorts highest if ($a === null) { return ($b === null) ? 0 : $this->ascending; } if ($b === null) { return -$this->ascending; } // int|float sorts lowest $numericA = is_int($a) || is_float($a); $numericB = is_int($b) || is_float($b); if ($numericA && $numericB) { if ($a == $b) { return 0; } return ($a < $b) ? -$this->ascending : $this->ascending; } if ($numericA) { return -$this->ascending; } if ($numericB) { return $this->ascending; } // bool sorts higher than string if (is_bool($a)) { if (!is_bool($b)) { return $this->ascending; } if ($a) { return $b ? 0 : $this->ascending; } return $b ? -$this->ascending : 0; } if (is_bool($b)) { return -$this->ascending; } // special handling for numeric strings starting with - /** @var string $a */ $a2 = (string) preg_replace('/^-(\d)+$/', '$1', $a); /** @var string $b */ $b2 = (string) preg_replace('/^-(\d)+$/', '$1', $b); // strings sort case-insensitive return $this->ascending * strcasecmp($a2, $b2); } /** * @param mixed[] $array */ public function sortArray(array &$array, int $ascending = self::ASCENDING, int $arrayCol = 0): void { if ($ascending !== 1 && $ascending !== -1) { throw new Exception('ascending must be 1 or -1'); } $this->ascending = $ascending; $this->arrayCol = $arrayCol; usort($array, $this->cmp(...)); } } require __DIR__ . '/../Header.php'; /** @var Sample $helper */ $helper->log('Emulating how Excel sorts different DataTypes by Column'); $array = [ ['a', 'a', 'a'], ['a', 'a', 'b'], ['a', null, 'c'], ['b', 'b', 1], ['b', 'c', 2], ['b', 'c', true], ['c', 1, false], ['c', 1, 'a'], ['c', 2, 'b'], [1, 2, 'c'], [1, true, 1], [1, true, 2], [2, false, true], [2, false, false], [2, 'a', false], [true, 'b', true], [true, 'c', 2], [true, 1, 1], [false, 2, 'a'], [false, true, 'b'], [false, false, 'c'], ]; /** @param array<int, array<int, mixed>> $original */ function displaySortedCols(array $original, Sample $helper): void { $sorted = $original; $sortExcelCols = new SortExcelCols(); $helper->log('Sort by least significant column (descending)'); $sortExcelCols->sortArray($sorted, arrayCol: 2, ascending: -1); $helper->log('Sort by middle column (ascending)'); $sortExcelCols->sortArray($sorted, arrayCol: 1, ascending: 1); $helper->log('Sort by most significant column (descending)'); $sortExcelCols->sortArray($sorted, arrayCol: 0, ascending: -1); $outArray = [['Original', '', '', 'Sorted', '', '']]; $count = count($original); /** @var string[][] $sorted */ for ($i = 0; $i < $count; ++$i) { $outArray[] = [ $original[$i][0], $original[$i][1], $original[$i][2], $sorted[$i][0], $sorted[$i][1], $sorted[$i][2], ]; } $helper->displayGrid($outArray, TextGridRightAlign::floatOrInt); } displaySortedCols($array, $helper);
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/LookupRef/COLUMN.php
samples/LookupRef/COLUMN.php
<?php use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $helper->log('Returns the column index of a cell.'); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $calculation = Calculation::getInstance($spreadsheet); $calculation->setInstanceArrayReturnType( Calculation::RETURN_ARRAY_AS_VALUE ); $worksheet = $spreadsheet->getActiveSheet(); $worksheet->getCell('A1')->setValue('=COLUMN(C13)'); $worksheet->getCell('A2')->setValue('=COLUMN(E13:G15)'); $worksheet->getCell('F1')->setValue('=COLUMN()'); for ($row = 1; $row <= 2; ++$row) { $cell = $worksheet->getCell("A{$row}"); $helper->log("A{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString()); } $cell = $worksheet->getCell('F1'); $helper->log('F1: ' . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString());
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/LookupRef/INDEX.php
samples/LookupRef/INDEX.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $helper->log('Returns the row index of a cell.'); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); $data1 = [ ['Apples', 'Lemons'], ['Bananas', 'Pears'], ]; $data2 = [ [4, 6], [5, 3], [6, 9], [7, 5], [8, 3], ]; $worksheet->fromArray($data1, null, 'A1'); $worksheet->fromArray($data2, null, 'C1'); $worksheet->getCell('A11')->setValue('=INDEX(A1:B2, 2, 2)'); $worksheet->getCell('A12')->setValue('=INDEX(A1:B2, 2, 1)'); $worksheet->getCell('A13')->setValue('=INDEX({1,2;3,4}, 0, 2)'); $worksheet->getCell('A14')->setValue('=INDEX(C1:C5, 5)'); $worksheet->getCell('A15')->setValue('=INDEX(C1:D5, 5, 2)'); $worksheet->getCell('A16')->setValue('=SUM(INDEX(C1:D5, 5, 0))'); for ($row = 11; $row <= 16; ++$row) { $cell = $worksheet->getCell("A{$row}"); $helper->log("A{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString()); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/LookupRef/ROW.php
samples/LookupRef/ROW.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $helper->log('Returns the row index of a cell.'); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); $worksheet->getCell('A1')->setValue('=ROW(C13)'); $worksheet->getCell('A2')->setValue('=ROW(E19:G21)'); $worksheet->getCell('A3')->setValue('=ROW()'); for ($row = 1; $row <= 3; ++$row) { $cell = $worksheet->getCell("A{$row}"); $helper->log("A{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString()); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/LookupRef/INDIRECT.php
samples/LookupRef/INDIRECT.php
<?php use PhpOffice\PhpSpreadsheet\NamedRange; use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $helper->log('Returns the cell specified by a text string.'); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); $data = [ [8, 9, 0], [3, 4, 5], [9, 1, 3], [4, 6, 2], ]; $worksheet->fromArray($data, null, 'C1'); $spreadsheet->addNamedRange(new NamedRange('NAMED_RANGE_FOR_CELL_D4', $worksheet, '="$D$4"')); $worksheet->getCell('A1')->setValue('=INDIRECT("C1")'); $worksheet->getCell('A2')->setValue('=INDIRECT("D"&4)'); $worksheet->getCell('A3')->setValue('=INDIRECT("E"&ROW())'); $worksheet->getCell('A4')->setValue('=SUM(INDIRECT("$C$4:$E$4"))'); $worksheet->getCell('A5')->setValue('=INDIRECT(NAMED_RANGE_FOR_CELL_D4)'); for ($row = 1; $row <= 5; ++$row) { $cell = $worksheet->getCell("A{$row}"); $helper->log("A{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString()); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/LookupRef/ROWS.php
samples/LookupRef/ROWS.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $helper->log('Returns the row index of a cell.'); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); $worksheet->getCell('A1')->setValue('=ROWS(C1:E4)'); $worksheet->getCell('A2')->setValue('=ROWS({1,2,3;4,5,6})'); $worksheet->getCell('A3')->setValue('=ROWS(C1:E4 D3:G5)'); for ($row = 1; $row <= 3; ++$row) { $cell = $worksheet->getCell("A{$row}"); $helper->log("A{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString()); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/LookupRef/ADDRESS.php
samples/LookupRef/ADDRESS.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $helper->log('Returns a text reference to a single cell in a worksheet.'); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); $worksheet->getCell('A1')->setValue('=ADDRESS(2,3)'); $worksheet->getCell('A2')->setValue('=ADDRESS(2,3,2)'); $worksheet->getCell('A3')->setValue('=ADDRESS(2,3,2,FALSE)'); $worksheet->getCell('A4')->setValue('=ADDRESS(2,3,1,FALSE,"[Book1.xlsx]Sheet1")'); $worksheet->getCell('A5')->setValue('=ADDRESS(2,3,1,FALSE,"EXCEL SHEET")'); for ($row = 1; $row <= 5; ++$row) { $cell = $worksheet->getCell("A{$row}"); $helper->log("A{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString()); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/LookupRef/VLOOKUP.php
samples/LookupRef/VLOOKUP.php
<?php use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $helper->log('Searches for a value in the top row of a table or an array of values, and then returns a value in the same column from a row you specify in the table or array.'); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); $data = [ ['ID', 'First Name', 'Last Name', 'Salary'], [72, 'Emily', 'Smith', 64901], [66, 'James', 'Anderson', 70855], [14, 'Mia', 'Clark', 188657], [30, 'John', 'Lewis', 97566], [53, 'Jessica', 'Walker', 58339], [56, 'Mark', 'Reed', 125180], [79, 'Richard', 'Lopez', 91632], ]; $worksheet->fromArray($data, null, 'B2'); $lookupFields = [ ['ID', 53, 66, 56], ['Name'], ['Salary'], ]; $worksheet->fromArray($lookupFields, null, 'G3'); $worksheet->getCell('H4')->setValue('=VLOOKUP(H3, B3:E9, 2, FALSE) & " " & VLOOKUP(H3, B3:E9, 3, FALSE)'); $worksheet->getCell('I4')->setValue('=VLOOKUP(I3, B3:E9, 2, FALSE) & " " & VLOOKUP(I3, B3:E9, 3, FALSE)'); $worksheet->getCell('J4')->setValue('=VLOOKUP(J3, B3:E9, 2, FALSE) & " " & VLOOKUP(J3, B3:E9, 3, FALSE)'); $worksheet->getCell('H5')->setValue('=VLOOKUP(H3, B3:E9, 4, FALSE)'); $worksheet->getCell('I5')->setValue('=VLOOKUP(I3, B3:E9, 4, FALSE)'); $worksheet->getCell('J5')->setValue('=VLOOKUP(J3, B3:E9, 4, FALSE)'); for ($column = 'H'; $column !== 'K'; StringHelper::stringIncrement($column)) { for ($row = 4; $row <= 5; ++$row) { $cell = $worksheet->getCell("{$column}{$row}"); $helper->log("{$column}{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString()); } }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/LookupRef/OFFSET.php
samples/LookupRef/OFFSET.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $helper->log('Returns a cell range that is a specified number of rows and columns from a cell or range of cells.'); // Create new PhpSpreadsheet object $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); $data = [ [null, 'Week 1', 'Week 2', 'Week 3', 'Week 4'], ['Sunday', 4500, 2200, 3800, 1500], ['Monday', 5500, 6100, 5200, 4800], ['Tuesday', 7000, 6200, 5000, 7100], ['Wednesday', 8000, 4000, 3900, 7600], ['Thursday', 5900, 5500, 6900, 7100], ['Friday', 4900, 6300, 6900, 5200], ['Saturday', 3500, 3900, 5100, 4100], ]; $worksheet->fromArray($data, null, 'A3'); $worksheet->getCell('H1')->setValue('=OFFSET(A3, 3, 1)'); $worksheet->getCell('H2')->setValue('=SUM(OFFSET(A3, 3, 1, 1, 4))'); $worksheet->getCell('H3')->setValue('=SUM(OFFSET(B3:E3, 3, 0))'); $worksheet->getCell('H4')->setValue('=SUM(OFFSET(E3, 1, -3, 7))'); for ($row = 1; $row <= 4; ++$row) { $cell = $worksheet->getCell("H{$row}"); $helper->log("H{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString()); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Wizards/Header.php
samples/Wizards/Header.php
<?php require __DIR__ . '/../Header.php';
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Wizards/NumberFormat/Number.php
samples/Wizards/NumberFormat/Number.php
<?php use PhpOffice\PhpSpreadsheet\Exception as SpreadsheetException; use PhpOffice\PhpSpreadsheet\Helper\Sample; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard; require __DIR__ . '/../Header.php'; /** @var Sample $helper */ $helper = new Sample(); if ($helper->isCli()) { $helper->log('This example should only be run from a Web Browser' . PHP_EOL); return; } ?> <form action="Number.php" method="POST"> <div class="mb-3 row"> <label for="number" class="col-sm-2 col-form-label">Sample Number Value</label> <div class="col-sm-10"> <input name="number" type="text" size="8" value="<?php echo StringHelper::convertPostToString('number', '1234.5678'); ?>"> </div> </div> <div class="mb-3 row"> <hr /> </div> <div class="mb-3 row"> <label for="decimals" class="col-sm-2 col-form-label">Decimal Places</label> <div class="col-sm-10"> <input name="decimals" type="number" size="2" min="0" max="14" value="<?php echo StringHelper::convertPostToString('decimals', '2'); ?>"> </div> </div> <div class="mb-3 row"> <label for="thousands" class="col-sm-2 col-form-label">Use Thousands Separator</label> <div class="col-sm-10"> <input name="thousands" type="checkbox" <?php echo (isset($_POST['thousands'])) ? 'value="on"' : ''; ?> <?php echo (isset($_POST['thousands'])) ? 'checked' : ''; ?>> </div> </div> <div class="mb-3 row"> <div class="col-sm-10"> <input class="btn btn-primary" name="submit" type="submit" value="Display Mask"><br /> </div> </div> </form> <?php /** If the user has submitted the form, then we need to use the wizard to build a mask and display the result */ if (isset($_POST['submit'])) { if (!is_numeric($_POST['number'])) { $helper->log('The Sample Number Value must be numeric'); } elseif (!is_numeric($_POST['decimals']) || str_contains((string) $_POST['decimals'], '.') || (int) $_POST['decimals'] < 0) { $helper->log('The Decimal Places value must be positive integer'); } else { try { $wizard = new Wizard\Number((int) $_POST['decimals'], isset($_POST['thousands'])); $mask = $wizard->format(); $example = NumberFormat::toFormattedString((float) $_POST['number'], $mask); $helper->log('<hr /><b>Code:</b><br />'); $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); $helper->log( "\$mask = Wizard\\Number({$_POST['decimals']}, Wizard\\Number::" . (isset($_POST['thousands']) ? 'WITH_THOUSANDS_SEPARATOR' : 'WITHOUT_THOUSANDS_SEPARATOR') . ');<br />' ); $helper->log('echo (string) $mask;'); $helper->log('<hr /><b>Mask:</b>'); $helper->log($mask); $helper->log('<b>Example:</b>'); $helper->log($example); } catch (SpreadsheetException $e) { $helper->log("Exception: {$e->getMessage()}"); } } }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Wizards/NumberFormat/Currency.php
samples/Wizards/NumberFormat/Currency.php
<?php use PhpOffice\PhpSpreadsheet\Exception as SpreadsheetException; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard; use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard\CurrencyNegative; use PhpOffice\PhpSpreadsheet\Writer\Html as HtmlWriter; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ if ($helper->isCli()) { $helper->log('This example should only be run from a Web Browser' . PHP_EOL); return; } $negatives = [ CurrencyNegative::minus, CurrencyNegative::redMinus, CurrencyNegative::parentheses, CurrencyNegative::redParentheses, ]; $negativesString = [ 'CurrencyNegative::minus', 'CurrencyNegative::redMinus', 'CurrencyNegative::parentheses', 'CurrencyNegative::redParentheses', ]; $currencies = [ '$' => 'US Dollars ($)', '€' => 'Euro (€)', '¥' => 'Japanese Yen (¥)', '£' => 'Pound Sterling (£)', '₹' => 'Rupee (₹)', '₽' => 'Rouble (₽)', ]; $postNegative = StringHelper::convertPostToString('negative'); if (!in_array($postNegative, ['0', '1', '2', '3'], true)) { $postNegative = '0'; } $postNegative = (int) $postNegative; ?> <form action="Currency.php" method="POST"> <div class="mb-3 row"> <label for="number" class="col-sm-2 col-form-label">Sample Number Value</label> <div class="col-sm-10"> <input name="number" type="text" size="8" value="<?php echo StringHelper::convertPostToString('number', '1234.5678'); ?>"> </div> </div> <div class="mb-3 row"> <hr /> </div> <div class="mb-3 row"> <label for="currency" class="col-sm-2 col-form-label">Currency</label> <div class="col-sm-10"> <select name="currency" class="form-select"> <?php foreach ($currencies as $currencySymbol => $currencyName) { echo "<option value=\"{$currencySymbol}\" " . ((isset($_POST['currency']) && $_POST['currency'] === $currencySymbol) ? 'selected' : '') . ">{$currencyName}</option>", PHP_EOL; } ?> </select> </div> </div> <div class="mb-3 row"> <label for="decimals" class="col-sm-2 col-form-label">Decimal Places</label> <div class="col-sm-10"> <input name="decimals" type="number" size="2" min="0" max="14" value="<?php echo StringHelper::convertPostToString('decimals', '2'); ?>"> </div> </div> <div class="mb-3 row"> <label for="thousands" class="col-sm-2 col-form-label">Use Thousands Separator</label> <div class="col-sm-10"> <input name="thousands" type="checkbox" <?php echo (isset($_POST['thousands'])) ? 'value="on"' : ''; ?> <?php echo (isset($_POST['thousands'])) ? 'checked' : ''; ?>> </div> </div> <div class="mb-3 row"> <label for="position" class="col-sm-2 col-form-label">Currency Position</label> <div class="col-sm-10"> <input name="position" type="radio" value="1" <?php echo ((isset($_POST['position']) === false) || ($_POST['position'] === '1')) ? 'checked' : ''; ?>>Leading <input name="position" type="radio" value="0" <?php echo (isset($_POST['position']) && $_POST['position'] === '0') ? 'checked' : ''; ?>>Trailing </div> </div> <div class="mb-3 row"> <label for="negative" class="col-sm-2 col-form-label">Negative Numbers</label> <div class="col-sm-10"> <input name="negative" type="radio" value="0" <?php echo ($postNegative === 0) ? 'checked' : ''; ?>>Minus Sign <input name="negative" type="radio" value="1" <?php echo ($postNegative === 1) ? 'checked' : ''; ?>>Red Minus Sign <input name="negative" type="radio" value="2" <?php echo ($postNegative === 2) ? 'checked' : ''; ?>>Parentheses <input name="negative" type="radio" value="3" <?php echo ($postNegative === 3) ? 'checked' : ''; ?>>Red Parentheses </div> </div> <div class="mb-3 row"> <div class="col-sm-10"> <input class="btn btn-primary" name="submit" type="submit" value="Display Mask"><br /> </div> </div> </form> <?php /** If the user has submitted the form, then we need to use the wizard to build a mask and display the result */ if (isset($_POST['submit'])) { if (!is_numeric($_POST['number'])) { $helper->log('The Sample Number Value must be numeric'); } elseif (!is_numeric($_POST['decimals']) || str_contains((string) $_POST['decimals'], '.') || (int) $_POST['decimals'] < 0) { $helper->log('The Decimal Places value must be positive integer'); } elseif (!in_array($_POST['currency'], array_keys($currencies), true)) { $helper->log('Unrecognized currency symbol'); } else { try { $negative = $negatives[$postNegative]; $wizard = new Wizard\Currency($_POST['currency'], (int) $_POST['decimals'], isset($_POST['thousands']), (bool) $_POST['position']); $wizard->setNegative($negative); $mask = $wizard->format(); $example = (string) NumberFormat::toFormattedString((float) $_POST['number'], $mask, [HtmlWriter::class, 'formatColorStatic']); $helper->log('<hr /><b>Code:</b><br />'); $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\CurrencyNegative;'); $helper->log( "\$wizard = new Wizard\\Currency('{$_POST['currency']}', {$_POST['decimals']}, Wizard\\Number::" . (isset($_POST['thousands']) ? 'WITH_THOUSANDS_SEPARATOR' : 'WITHOUT_THOUSANDS_SEPARATOR') . ', Wizard\Currency::' . (((bool) $_POST['position']) ? 'LEADING_SYMBOL' : 'TRAILING_SYMBOL') . ');' ); $helper->log('$wizard->setNegative(' . $negativesString[$postNegative] . ');'); $helper->log('$mask = $wizard->format();'); $helper->log('<br />echo (string) $mask;'); $helper->log('<hr /><b>Mask:</b><br />'); $helper->log($mask . '<br />'); $helper->log('<br /><b>Example:</b><br />'); $helper->log($example); } catch (SpreadsheetException $e) { $helper->log("Exception: {$e->getMessage()}"); } } }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Wizards/NumberFormat/Percentage.php
samples/Wizards/NumberFormat/Percentage.php
<?php use PhpOffice\PhpSpreadsheet\Exception as SpreadsheetException; use PhpOffice\PhpSpreadsheet\Helper\Sample; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard; require __DIR__ . '/../Header.php'; /** @var Sample $helper */ $helper = new Sample(); if ($helper->isCli()) { $helper->log('This example should only be run from a Web Browser' . PHP_EOL); return; } ?> <form action="Percentage.php" method="POST"> <div class="mb-3 row"> <label for="number" class="col-sm-2 col-form-label">Sample Number Value</label> <div class="col-sm-10"> <input name="number" type="text" size="8" value="<?php echo StringHelper::convertPostToString('number', '1234.5678'); ?>"> </div> </div> <div class="mb-3 row"> <hr /> </div> <div class="mb-3 row"> <label for="decimals" class="col-sm-2 col-form-label">Decimal Places</label> <div class="col-sm-10"> <input name="decimals" type="number" size="2" min="0" max="14" value="<?php echo StringHelper::convertPostToString('decimals', '2'); ?>"> </div> </div> <div class="mb-3 row"> <div class="col-sm-10"> <input class="btn btn-primary" name="submit" type="submit" value="Display Mask"><br /> </div> </div> </form> <?php /** If the user has submitted the form, then we need to use the wizard to build a mask and display the result */ if (isset($_POST['submit'])) { if (!is_numeric($_POST['number'])) { $helper->log('The Sample Number Value must be numeric'); } elseif (!is_numeric($_POST['decimals']) || str_contains((string) $_POST['decimals'], '.') || (int) $_POST['decimals'] < 0) { $helper->log('The Decimal Places value must be positive integer'); } else { try { $wizard = new Wizard\Percentage((int) $_POST['decimals']); $mask = $wizard->format(); $example = (string) NumberFormat::toFormattedString((float) $_POST['number'], $mask); $helper->log('<hr /><b>Code:</b><br />'); $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); $helper->log("\$mask = Wizard\\Percentage({$_POST['decimals']});<br />"); $helper->log('echo (string) $mask;'); $helper->log('<hr /><b>Mask:</b><br />'); $helper->log($mask . '<br />'); $helper->log('<br /><b>Example:</b><br />'); $helper->log($example); } catch (SpreadsheetException $e) { $helper->log("Exception: {$e->getMessage()}"); } } }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Wizards/NumberFormat/Accounting.php
samples/Wizards/NumberFormat/Accounting.php
<?php use PhpOffice\PhpSpreadsheet\Exception as SpreadsheetException; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ if ($helper->isCli()) { $helper->log('This example should only be run from a Web Browser' . PHP_EOL); return; } $currencies = [ '$' => 'US Dollars ($)', '€' => 'Euro (€)', '¥' => 'Japanese Yen (¥)', '£' => 'Pound Sterling (£)', '₹' => 'Rupee (₹)', '₽' => 'Rouble (₽)', ]; ?> <form action=Accounting.php method="POST"> <div class="mb-3 row"> <label for="number" class="col-sm-2 col-form-label">Sample Number Value</label> <div class="col-sm-10"> <input name="number" type="text" size="8" value="<?php echo StringHelper::convertPostToString('number', '1234.5678'); ?>"> </div> </div> <div class="mb-3 row"> <hr /> </div> <div class="mb-3 row"> <label for="currency" class="col-sm-2 col-form-label">Currency</label> <div class="col-sm-10"> <select name="currency" class="form-select"> <?php foreach ($currencies as $currencySymbol => $currencyName) { echo "<option value=\"{$currencySymbol}\" " . ((isset($_POST['currency']) && $_POST['currency'] === $currencySymbol) ? 'selected' : '') . ">{$currencyName}</option>", PHP_EOL; } ?> </select> </div> </div> <div class="mb-3 row"> <label for="decimals" class="col-sm-2 col-form-label">Decimal Places</label> <div class="col-sm-10"> <input name="decimals" type="number" size="2" min="0" max="14" value="<?php echo StringHelper::convertPostToString('decimals', '2'); ?>"> </div> </div> <div class="mb-3 row"> <label for="thousands" class="col-sm-2 col-form-label">Use Thousands Separator</label> <div class="col-sm-10"> <input name="thousands" type="checkbox" <?php echo (isset($_POST['thousands'])) ? 'value="on"' : ''; ?> <?php echo (isset($_POST['thousands'])) ? 'checked' : ''; ?>> </div> </div> <div class="mb-3 row"> <label for="position" class="col-sm-2 col-form-label">Currency Position</label> <div class="col-sm-10"> <input name="position" type="radio" value="1" <?php echo ((isset($_POST['position']) === false) || ($_POST['position'] === '1')) ? 'checked' : ''; ?>>Leading <input name="position" type="radio" value="0" <?php echo (isset($_POST['position']) && $_POST['position'] === '0') ? 'checked' : ''; ?>>Trailing </div> </div> <div class="mb-3 row"> <div class="col-sm-10"> <input class="btn btn-primary" name="submit" type="submit" value="Display Mask"><br /> </div> </div> </form> <?php /** If the user has submitted the form, then we need to use the wizard to build a mask and display the result */ if (isset($_POST['submit'])) { if (!is_numeric($_POST['number'])) { $helper->log('The Sample Number Value must be numeric'); } elseif (!is_numeric($_POST['decimals']) || str_contains((string) $_POST['decimals'], '.') || (int) $_POST['decimals'] < 0) { $helper->log('The Decimal Places value must be positive integer'); } elseif (!in_array($_POST['currency'], array_keys($currencies), true)) { $helper->log('Unrecognized currency symbol'); } else { try { $wizard = new Wizard\Accounting($_POST['currency'], (int) $_POST['decimals'], isset($_POST['thousands']), (bool) $_POST['position']); $mask = $wizard->format(); $example = (string) NumberFormat::toFormattedString((float) $_POST['number'], $mask); $helper->log('<hr /><b>Code:</b><br />'); $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); $helper->log( "\$wizard = new Wizard\\Accounting('{$_POST['currency']}', {$_POST['decimals']}, Wizard\\Number::" . (isset($_POST['thousands']) ? 'WITH_THOUSANDS_SEPARATOR' : 'WITHOUT_THOUSANDS_SEPARATOR') . ', Wizard\Currency::' . (((bool) $_POST['position']) ? 'LEADING_SYMBOL' : 'TRAILING_SYMBOL') . ');' ); $helper->log('$mask = $wizard->format();'); $helper->log('<br />echo (string) $mask;'); $helper->log('<hr /><b>Mask:</b><br />'); $helper->log($mask . '<br />'); $helper->log('<br /><b>Example:</b><br />'); $helper->log($example); } catch (SpreadsheetException $e) { $helper->log("Exception: {$e->getMessage()}"); } } }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Wizards/NumberFormat/Scientific.php
samples/Wizards/NumberFormat/Scientific.php
<?php use PhpOffice\PhpSpreadsheet\Exception as SpreadsheetException; use PhpOffice\PhpSpreadsheet\Helper\Sample; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard; require __DIR__ . '/../Header.php'; /** @var Sample $helper */ $helper = new Sample(); if ($helper->isCli()) { $helper->log('This example should only be run from a Web Browser' . PHP_EOL); return; } ?> <form action="Scientific.php" method="POST"> <div class="mb-3 row"> <label for="number" class="col-sm-2 col-form-label">Sample Number Value</label> <div class="col-sm-10"> <input name="number" type="text" size="8" value="<?php echo StringHelper::convertPostToString('number', '1234.5678'); ?>"> </div> </div> <div class="mb-3 row"> <hr /> </div> <div class="mb-3 row"> <label for="decimals" class="col-sm-2 col-form-label">Decimal Places</label> <div class="col-sm-10"> <input name="decimals" type="number" size="2" min="0" max="14" value="<?php echo StringHelper::convertPostToString('decimals', '2'); ?>"> </div> </div> <div class="mb-3 row"> <div class="col-sm-10"> <input class="btn btn-primary" name="submit" type="submit" value="Display Mask"><br /> </div> </div> </form> <?php /** If the user has submitted the form, then we need to use the wizard to build a mask and display the result */ if (isset($_POST['submit'])) { if (!is_numeric($_POST['number'])) { $helper->log('The Sample Number Value must be numeric'); } elseif (!is_numeric($_POST['decimals']) || str_contains((string) $_POST['decimals'], '.') || (int) $_POST['decimals'] < 0) { $helper->log('The Decimal Places value must be positive integer'); } else { try { $wizard = new Wizard\Scientific((int) $_POST['decimals']); $mask = $wizard->format(); $example = (string) NumberFormat::toFormattedString((float) $_POST['number'], $mask); $helper->log('<hr /><b>Code:</b><br />'); $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); $helper->log("\$mask = Wizard\\Scientific({$_POST['decimals']});<br />"); $helper->log('echo (string) $mask;'); $helper->log('<hr /><b>Mask:</b><br />'); $helper->log($mask . '<br />'); $helper->log('<br /><b>Example:</b><br />'); $helper->log($example); } catch (SpreadsheetException $e) { $helper->log("Exception: {$e->getMessage()}"); } } }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reading_workbook_data/Custom_properties.php
samples/Reading_workbook_data/Custom_properties.php
<?php use PhpOffice\PhpSpreadsheet\IOFactory; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $inputFileType = 'Xlsx'; $inputFileName = __DIR__ . '/sampleData/example1.xlsx'; // Create a new Reader of the type defined in $inputFileType $reader = IOFactory::createReader($inputFileType); // Load $inputFileName to a PhpSpreadsheet Object $spreadsheet = $reader->load($inputFileName); // Read an array list of any custom properties for this document $customPropertyList = $spreadsheet->getProperties()->getCustomProperties(); // Loop through the list of custom properties foreach ($customPropertyList as $customPropertyName) { $helper->log('<b>' . $customPropertyName . ': </b>'); // Retrieve the property value $propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customPropertyName); // Retrieve the property type $propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customPropertyName); // Manipulate properties as appropriate for display purposes switch ($propertyType) { case 'i': // integer $propertyType = 'integer number'; break; case 'f': // float $propertyType = 'floating point number'; break; case 's': // string $propertyType = 'string'; break; case 'd': // date $propertyValue = is_numeric($propertyValue) ? date('l, j<\s\u\p>S</\s\u\p> F Y g:i A', (int) $propertyValue) : '*****INVALID*****'; $propertyType = 'date'; break; case 'b': // boolean $propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE'; $propertyType = 'boolean'; break; } $helper->log($propertyValue . ' (' . $propertyType . ')'); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reading_workbook_data/Properties.php
samples/Reading_workbook_data/Properties.php
<?php use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Shared\Date; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $inputFileType = 'Xls'; $inputFileName = __DIR__ . '/sampleData/example1.xls'; // Create a new Reader of the type defined in $inputFileType $reader = IOFactory::createReader($inputFileType); // Load $inputFileName to a PhpSpreadsheet Object $spreadsheet = $reader->load($inputFileName); // Read the document's creator property $creator = $spreadsheet->getProperties()->getCreator(); $helper->log('<b>Document Creator: </b>' . $creator); // Read the Date when the workbook was created (as a PHP timestamp value) $creationDatestamp = $spreadsheet->getProperties()->getCreated(); $creationDate = Date::formattedDateTimeFromTimestamp("$creationDatestamp", 'l, j<\s\u\p>S</\s\u\p> F Y'); $creationTime = Date::formattedDateTimeFromTimestamp("$creationDatestamp", 'g:i A'); $helper->log('<b>Created On: </b>' . $creationDate . ' at ' . $creationTime); // Read the name of the last person to modify this workbook $modifiedBy = $spreadsheet->getProperties()->getLastModifiedBy(); $helper->log('<b>Last Modified By: </b>' . $modifiedBy); // Read the Date when the workbook was last modified (as a PHP timestamp value) $modifiedDatestamp = $spreadsheet->getProperties()->getModified(); // Format the date and time using the standard PHP date() function $modifiedDate = Date::formattedDateTimeFromTimestamp("$modifiedDatestamp", 'l, j<\s\u\p>S</\s\u\p> F Y'); $modifiedTime = Date::formattedDateTimeFromTimestamp("$modifiedDatestamp", 'g:i A'); $helper->log('<b>Last Modified On: </b>' . $modifiedDate . ' at ' . $modifiedTime); // Read the workbook title property $workbookTitle = $spreadsheet->getProperties()->getTitle(); $helper->log('<b>Title: </b>' . $workbookTitle); // Read the workbook description property $description = $spreadsheet->getProperties()->getDescription(); $helper->log('<b>Description: </b>' . $description); // Read the workbook subject property $subject = $spreadsheet->getProperties()->getSubject(); $helper->log('<b>Subject: </b>' . $subject); // Read the workbook keywords property $keywords = $spreadsheet->getProperties()->getKeywords(); $helper->log('<b>Keywords: </b>' . $keywords); // Read the workbook category property $category = $spreadsheet->getProperties()->getCategory(); $helper->log('<b>Category: </b>' . $category); // Read the workbook company property $company = $spreadsheet->getProperties()->getCompany(); $helper->log('<b>Company: </b>' . $company); // Read the workbook manager property $manager = $spreadsheet->getProperties()->getManager(); $helper->log('<b>Manager: </b>' . $manager); $s = new PhpOffice\PhpSpreadsheet\Helper\Sample();
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reading_workbook_data/Custom_property_names.php
samples/Reading_workbook_data/Custom_property_names.php
<?php use PhpOffice\PhpSpreadsheet\IOFactory; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $inputFileType = 'Xlsx'; $inputFileName = __DIR__ . '/sampleData/example1.xlsx'; // Create a new Reader of the type defined in $inputFileType $reader = IOFactory::createReader($inputFileType); // Load $inputFileName to a PhpSpreadsheet Object $spreadsheet = $reader->load($inputFileName); // Read an array list of any custom properties for this document $customPropertyList = $spreadsheet->getProperties()->getCustomProperties(); foreach ($customPropertyList as $customPropertyName) { $helper->log($customPropertyName); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reading_workbook_data/Worksheet_count_and_names.php
samples/Reading_workbook_data/Worksheet_count_and_names.php
<?php use PhpOffice\PhpSpreadsheet\IOFactory; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $inputFileType = 'Xls'; $inputFileName = __DIR__ . '/sampleData/example2.xls'; // Create a new Reader of the type defined in $inputFileType $reader = IOFactory::createReader($inputFileType); // Load $inputFileName to a PhpSpreadsheet Object $spreadsheet = $reader->load($inputFileName); // Use the PhpSpreadsheet object's getSheetCount() method to get a count of the number of WorkSheets in the WorkBook $sheetCount = $spreadsheet->getSheetCount(); $helper->log('There ' . (($sheetCount == 1) ? 'is' : 'are') . ' ' . $sheetCount . ' WorkSheet' . (($sheetCount == 1) ? '' : 's') . ' in the WorkBook'); $helper->log('Reading the names of Worksheets in the WorkBook'); // Use the PhpSpreadsheet object's getSheetNames() method to get an array listing the names/titles of the WorkSheets in the WorkBook $sheetNames = $spreadsheet->getSheetNames(); foreach ($sheetNames as $sheetIndex => $sheetName) { $helper->log('WorkSheet #' . $sheetIndex . ' is named "' . $sheetName . '"'); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reader2/15_Simple_file_reader_for_tab_separated_value_file_using_the_Advanced_Value_Binder.php
samples/Reader2/15_Simple_file_reader_for_tab_separated_value_file_using_the_Advanced_Value_Binder.php
<?php use PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder; use PhpOffice\PhpSpreadsheet\Cell\Cell; use PhpOffice\PhpSpreadsheet\Reader\Csv; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ Cell::setValueBinder(new AdvancedValueBinder()); $inputFileName = __DIR__ . '/sampleData/example1.tsv'; $reader = new Csv(); $helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' into WorkSheet #1 using Csv reader'); $reader->setDelimiter("\t"); $spreadsheet = $reader->load($inputFileName); $spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME)); $helper->log($spreadsheet->getSheetCount() . ' worksheet' . (($spreadsheet->getSheetCount() == 1) ? '' : 's') . ' loaded'); $loadedSheetNames = $spreadsheet->getSheetNames(); foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { $helper->log('<b>Worksheet #' . $sheetIndex . ' -> ' . $loadedSheetName . ' (Formatted)</b>'); $spreadsheet->setActiveSheetIndexByName($loadedSheetName); $activeRange = $spreadsheet->getActiveSheet()->calculateWorksheetDataDimension(); $sheetData = $spreadsheet->getActiveSheet()->rangeToArray($activeRange, null, true, true, true); $helper->displayGrid($sheetData); } foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { $helper->log('<b>Worksheet #' . $sheetIndex . ' -> ' . $loadedSheetName . ' (Unformatted)</b>'); $spreadsheet->setActiveSheetIndexByName($loadedSheetName); $activeRange = $spreadsheet->getActiveSheet()->calculateWorksheetDataDimension(); $sheetData = $spreadsheet->getActiveSheet()->rangeToArray($activeRange, null, true, true, true); $helper->displayGrid($sheetData); } foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { $helper->log('<b>Worksheet #' . $sheetIndex . ' -> ' . $loadedSheetName . ' (Raw)</b>'); $spreadsheet->setActiveSheetIndexByName($loadedSheetName); $activeRange = $spreadsheet->getActiveSheet()->calculateWorksheetDataDimension(); $sheetData = $spreadsheet->getActiveSheet()->rangeToArray($activeRange, null, true, true, true); $helper->displayGrid($sheetData); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reader2/22_Reader_formscomments.php
samples/Reader2/22_Reader_formscomments.php
<?php use PhpOffice\PhpSpreadsheet\IOFactory; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $helper->log('Start'); $inputFileType = 'Xlsx'; $inputFileName = __DIR__ . '/sampleData/formscomments.xlsx'; $helper->log('Loading file ' . $inputFileName . ' using IOFactory with a defined reader type of ' . $inputFileType); $reader = IOFactory::createReader($inputFileType); $helper->log('Loading all WorkSheets'); $reader->setLoadAllSheets(); $spreadsheet = $reader->load($inputFileName); // Save $helper->write($spreadsheet, __FILE__, ['Xlsx']); $spreadsheet->disconnectWorksheets(); $helper->log('end');
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reader2/23_iterateRowsYield.php
samples/Reader2/23_iterateRowsYield.php
<?php /** * Use rangeToArrayYieldRows() to efficiently iterate over all rows. */ use PhpOffice\PhpSpreadsheet\Shared\StringHelper; require __DIR__ . '/../Header.php'; $inputFileName = __DIR__ . '/../Reader/sampleData/example1.xls'; $spreadsheet = PhpOffice\PhpSpreadsheet\IOFactory::load( $inputFileName, PhpOffice\PhpSpreadsheet\Reader\IReader::READ_DATA_ONLY ); $sheet = $spreadsheet->getSheet(0); $rowGenerator = $sheet->rangeToArrayYieldRows( $spreadsheet->getActiveSheet()->calculateWorksheetDataDimension(), null, false, false ); foreach ($rowGenerator as $row) { echo '| ' . StringHelper::convertToString($row[0]) . ' | ' . StringHelper::convertToString($row[1]) . "|\n"; }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reader2/16_Handling_loader_exceptions_using_TryCatch.php
samples/Reader2/16_Handling_loader_exceptions_using_TryCatch.php
<?php use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $inputFileName = __DIR__ . '/sampleData/non-existing-file.xls'; $helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory to identify the format'); try { $spreadsheet = IOFactory::load($inputFileName); } catch (ReaderException $e) { $helper->log('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reader2/21_Reader_CSV_Long_Integers_with_String_Value_Binder.php
samples/Reader2/21_Reader_CSV_Long_Integers_with_String_Value_Binder.php
<?php use PhpOffice\PhpSpreadsheet\Cell\Cell; use PhpOffice\PhpSpreadsheet\Cell\StringValueBinder; use PhpOffice\PhpSpreadsheet\IOFactory; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ Cell::setValueBinder(new StringValueBinder()); $inputFileType = 'Csv'; $inputFileName = __DIR__ . '/sampleData/longIntegers.csv'; $reader = IOFactory::createReader($inputFileType); $helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' into WorkSheet #1 using IOFactory with a defined reader type of ' . $inputFileType); $spreadsheet = $reader->load($inputFileName); $spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME)); $helper->log($spreadsheet->getSheetCount() . ' worksheet' . (($spreadsheet->getSheetCount() == 1) ? '' : 's') . ' loaded'); $loadedSheetNames = $spreadsheet->getSheetNames(); foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { $helper->log('<b>Worksheet #' . $sheetIndex . ' -> ' . $loadedSheetName . ' (Formatted)</b>'); $spreadsheet->setActiveSheetIndexByName($loadedSheetName); $activeRange = $spreadsheet->getActiveSheet()->calculateWorksheetDataDimension(); $sheetData = $spreadsheet->getActiveSheet()->rangeToArray($activeRange, null, true, true, true); $helper->displayGrid($sheetData); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reader2/19_Reading_worksheet_information_without_loading_entire_file.php
samples/Reader2/19_Reading_worksheet_information_without_loading_entire_file.php
<?php use PhpOffice\PhpSpreadsheet\Reader\Xls; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $inputFileType = 'Xls'; $inputFileName = __DIR__ . '/sampleData/example1.xls'; $helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' information using Xls reader'); $reader = new Xls(); $worksheetData = $reader->listWorksheetInfo($inputFileName); $helper->log('<h3>Worksheet Information</h3>'); $helper->log('<ol>'); foreach ($worksheetData as $worksheet) { $helper->log('<li>' . $worksheet['worksheetName']); $helper->log('Rows: ' . $worksheet['totalRows'] . ' Columns: ' . $worksheet['totalColumns']); $helper->log('Cell Range: A1:' . $worksheet['lastColumnLetter'] . $worksheet['totalRows']); $helper->log('</li>'); } $helper->log('</ol>');
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reader2/20_Reader_worksheet_hyperlink_image.php
samples/Reader2/20_Reader_worksheet_hyperlink_image.php
<?php use PhpOffice\PhpSpreadsheet\Shared\File; use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $inputFileType = 'Xlsx'; $helper->log('Start'); $spreadsheet = new Spreadsheet(); $aSheet = $spreadsheet->getActiveSheet(); $gdImage = @imagecreatetruecolor(120, 20); if ($gdImage === false) { throw new Exception('imagecreatetruecolor failed'); } $textColor = imagecolorallocate($gdImage, 255, 255, 255); if ($textColor === false) { throw new Exception('imagecolorallocate failed'); } imagestring($gdImage, 1, 5, 5, 'Created with PhpSpreadsheet', $textColor); $baseUrl = 'https://phpspreadsheet.readthedocs.io'; $drawing = new PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing(); $drawing->setName('In-Memory image 1'); $drawing->setDescription('In-Memory image 1'); $drawing->setCoordinates('A1'); $drawing->setImageResource($gdImage); $drawing->setRenderingFunction( PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::RENDERING_JPEG ); $drawing->setMimeType(PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::MIMETYPE_DEFAULT); $drawing->setHeight(36); $helper->log('Write image'); $hyperLink = new PhpOffice\PhpSpreadsheet\Cell\Hyperlink($baseUrl, 'test image'); $drawing->setHyperlink($hyperLink); $helper->log('Write link: ' . $baseUrl); $drawing->setWorksheet($aSheet); $filename = File::temporaryFilename(); $writer = PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, $inputFileType); $writer->save($filename); $reader = PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); $reloadedSpreadsheet = $reader->load($filename); unlink($filename); $helper->log('reloaded Spreadsheet'); foreach ($reloadedSpreadsheet->getActiveSheet()->getDrawingCollection() as $pDrawing) { $helper->log('Read link: ' . ($pDrawing->getHyperlink()?->getUrl() ?? 'none')); } $helper->log('end');
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reader2/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php
samples/Reader2/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php
<?php namespace Samples\Sample14; use PhpOffice\PhpSpreadsheet\Reader\Csv; use PhpOffice\PhpSpreadsheet\Reader\IReadFilter; use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var \PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $inputFileName = __DIR__ . '/sampleData/example2.csv'; /** Define a Read Filter class implementing IReadFilter */ class ChunkReadFilter implements IReadFilter { private int $startRow = 0; private int $endRow = 0; /** * Set the list of rows that we want to read. */ public function setRows(int $startRow, int $chunkSize): void { $this->startRow = $startRow; $this->endRow = $startRow + $chunkSize; } public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { // Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) { return true; } return false; } } $helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using Csv reader'); // Create a new Reader of the type defined in $inputFileType $reader = new Csv(); // Define how many rows we want to read for each "chunk" $chunkSize = 100; // Create a new Instance of our Read Filter $chunkFilter = new ChunkReadFilter(); // Tell the Reader that we want to use the Read Filter that we've Instantiated // and that we want to store it in contiguous rows/columns $reader->setReadFilter($chunkFilter); $reader->setContiguous(true); // Instantiate a new PhpSpreadsheet object manually $spreadsheet = new Spreadsheet(); // Set a sheet index $sheet = 0; // Loop to read our worksheet in "chunk size" blocks /** $startRow is set to 2 initially because we always read the headings in row #1 * */ for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) { $helper->log('Loading WorkSheet #' . ($sheet + 1) . ' using configurable filter for headings row 1 and for rows ' . $startRow . ' to ' . ($startRow + $chunkSize - 1)); // Tell the Read Filter, the limits on which rows we want to read this iteration $chunkFilter->setRows($startRow, $chunkSize); // Increment the worksheet index pointer for the Reader $reader->setSheetIndex($sheet); // Load only the rows that match our filter into a new worksheet in the PhpSpreadsheet Object $reader->loadIntoExisting($inputFileName, $spreadsheet); // Set the worksheet title (to reference the "sheet" of data that we've loaded) // and increment the sheet index as well $spreadsheet->getActiveSheet()->setTitle('Country Data #' . (++$sheet)); } $helper->log($spreadsheet->getSheetCount() . ' worksheet' . (($spreadsheet->getSheetCount() == 1) ? '' : 's') . ' loaded'); $loadedSheetNames = $spreadsheet->getSheetNames(); foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { $helper->log('<b>Worksheet #' . $sheetIndex . ' -> ' . $loadedSheetName . '</b>'); $spreadsheet->setActiveSheetIndexByName($loadedSheetName); $sheet = $spreadsheet->getActiveSheet(); $activeRange = $sheet->calculateWorksheetDataDimension(); $sheet->getStyle($activeRange)->getNumberFormat() ->setFormatCode('0.000'); $sheetData = $sheet->rangeToArray($activeRange, null, true, true, true); $helper->displayGrid($sheetData, true); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reader2/22_Reader_issue1767.php
samples/Reader2/22_Reader_issue1767.php
<?php use PhpOffice\PhpSpreadsheet\IOFactory; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $helper->log('Start'); $inputFileType = 'Xlsx'; $inputFileName = __DIR__ . '/sampleData/issue.1767.xlsx'; $helper->log('Loading file ' . $inputFileName . ' using IOFactory with a defined reader type of ' . $inputFileType); $reader = IOFactory::createReader($inputFileType); $helper->log('Loading all WorkSheets'); $reader->setLoadAllSheets(); $spreadsheet = $reader->load($inputFileName); // Save $helper->write($spreadsheet, __FILE__); $spreadsheet->disconnectWorksheets(); $helper->log('end');
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reader2/17_Simple_file_reader_loading_several_named_worksheets.php
samples/Reader2/17_Simple_file_reader_loading_several_named_worksheets.php
<?php use PhpOffice\PhpSpreadsheet\Reader\Xls; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $inputFileName = __DIR__ . '/sampleData/example1.xls'; $helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using Xls reader'); $reader = new Xls(); // Read the list of Worksheet Names from the Workbook file $helper->log('Read the list of Worksheets in the WorkBook'); $worksheetNames = $reader->listWorksheetNames($inputFileName); $helper->log('There are ' . count($worksheetNames) . ' worksheet' . ((count($worksheetNames) == 1) ? '' : 's') . ' in the workbook'); foreach ($worksheetNames as $worksheetName) { $helper->log($worksheetName); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reader2/13_Simple_file_reader_for_multiple_CSV_files.php
samples/Reader2/13_Simple_file_reader_for_multiple_CSV_files.php
<?php use PhpOffice\PhpSpreadsheet\Reader\Csv; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $inputFileNames = [__DIR__ . '/sampleData/example1.csv', __DIR__ . '/sampleData/example2.csv']; $reader = new Csv(); $inputFileName = array_shift($inputFileNames); $helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' into WorkSheet #1 using Csv Reader'); $spreadsheet = $reader->load($inputFileName); $spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME)); foreach ($inputFileNames as $sheet => $inputFileName) { $helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' into WorkSheet #' . ($sheet + 2) . ' using Csv Reader'); $reader->setSheetIndex($sheet + 1); $reader->loadIntoExisting($inputFileName, $spreadsheet); $spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME)); } $helper->log($spreadsheet->getSheetCount() . ' worksheet' . (($spreadsheet->getSheetCount() == 1) ? '' : 's') . ' loaded'); $loadedSheetNames = $spreadsheet->getSheetNames(); foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { $helper->log('<b>Worksheet #' . $sheetIndex . ' -> ' . $loadedSheetName . '</b>'); $spreadsheet->setActiveSheetIndexByName($loadedSheetName); $sheet = $spreadsheet->getActiveSheet(); $activeRange = $sheet->calculateWorksheetDataDimension(); $sheet->getStyle($activeRange)->getNumberFormat() ->setFormatCode('0.000'); $sheetData = $sheet->rangeToArray($activeRange, null, true, true, true); $helper->displayGrid($sheetData, true); }
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Reader2/18_Reading_list_of_worksheets_without_loading_entire_file.php
samples/Reader2/18_Reading_list_of_worksheets_without_loading_entire_file.php
<?php use PhpOffice\PhpSpreadsheet\Reader\Xls; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $inputFileName = __DIR__ . '/sampleData/example1.xls'; $helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' information using Xls reader'); $reader = new Xls(); $worksheetNames = $reader->listWorksheetNames($inputFileName); $helper->log('<h3>Worksheet Names</h3>'); $helper->log('<ol>'); foreach ($worksheetNames as $worksheetName) { $helper->log('<li>' . $worksheetName . '</li>'); } $helper->log('</ol>');
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Basic/01_Simple_download_xlsx.php
samples/Basic/01_Simple_download_xlsx.php
<?php use PhpOffice\PhpSpreadsheet\Helper\Sample; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Spreadsheet; require_once __DIR__ . '/../Bootstrap.php'; $helper = new Sample(); if ($helper->isCli()) { $helper->log('This example should only be run from a Web Browser' . PHP_EOL); return; } // Create new Spreadsheet object $spreadsheet = new Spreadsheet(); // Set document properties $spreadsheet->getProperties()->setCreator('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw') ->setTitle('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setKeywords('office 2007 openxml php') ->setCategory('Test result file'); // Add some data $spreadsheet->setActiveSheetIndex(0) ->setCellValue('A1', 'Hello') ->setCellValue('B2', 'world!') ->setCellValue('C1', 'Hello') ->setCellValue('D2', 'world!'); // Miscellaneous glyphs, UTF-8 $spreadsheet->setActiveSheetIndex(0) ->setCellValue('A4', 'Miscellaneous glyphs') ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç'); // Rename worksheet $spreadsheet->getActiveSheet()->setTitle('Simple'); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $spreadsheet->setActiveSheetIndex(0); // Redirect output to a client’s web browser (Xlsx) header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="01simple.xlsx"'); header('Cache-Control: max-age=0'); // If you're serving to IE 9, then the following may be needed header('Cache-Control: max-age=1'); // If you're serving to IE over SSL, then the following may be needed header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified header('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header('Pragma: public'); // HTTP/1.0 $writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->save('php://output'); exit;
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Basic/09_Pagebreaks.php
samples/Basic/09_Pagebreaks.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ // Create new Spreadsheet object $helper->log('Create new Spreadsheet object'); $spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); $spreadsheet->getProperties()->setCreator('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw') ->setTitle('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setKeywords('office 2007 openxml php') ->setCategory('Test result file'); // Create a first sheet $helper->log('Add data and page breaks'); $spreadsheet->setActiveSheetIndex(0); $spreadsheet->getActiveSheet()->setCellValue('A1', 'Firstname') ->setCellValue('B1', 'Lastname') ->setCellValue('C1', 'Phone') ->setCellValue('D1', 'Fax') ->setCellValue('E1', 'Is Client ?'); // Add data for ($i = 2; $i <= 50; ++$i) { $spreadsheet->getActiveSheet()->setCellValue('A' . $i, "FName $i"); $spreadsheet->getActiveSheet()->setCellValue('B' . $i, "LName $i"); $spreadsheet->getActiveSheet()->setCellValue('C' . $i, "PhoneNo $i"); $spreadsheet->getActiveSheet()->setCellValue('D' . $i, "FaxNo $i"); $spreadsheet->getActiveSheet()->setCellValue('E' . $i, true); // Add page breaks every 10 rows if ($i % 10 == 0) { // Add a page break $spreadsheet->getActiveSheet()->setBreak('A' . $i, Worksheet::BREAK_ROW); } } // Set active sheet index to the first sheet, so Excel opens this as the first sheet $spreadsheet->setActiveSheetIndex(0); $spreadsheet->getActiveSheet()->setTitle('Printing Options'); // Set print headers $spreadsheet->getActiveSheet() ->getHeaderFooter()->setOddHeader('&C&24&K0000FF&B&U&A'); $spreadsheet->getActiveSheet() ->getHeaderFooter()->setEvenHeader('&C&24&K0000FF&B&U&A'); // Set print footers $spreadsheet->getActiveSheet() ->getHeaderFooter()->setOddFooter('&R&D &T&C&F&LPage &P / &N'); $spreadsheet->getActiveSheet() ->getHeaderFooter()->setEvenFooter('&L&D &T&C&F&RPage &P / &N'); // Save $helper->write($spreadsheet, __FILE__);
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Basic/01_Simple.php
samples/Basic/01_Simple.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $helper->log('Create new Spreadsheet object'); $spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); $spreadsheet->getProperties() ->setCreator('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw') ->setTitle('PhpSpreadsheet Test Document') ->setSubject('PhpSpreadsheet Test Document') ->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.') ->setKeywords('office PhpSpreadsheet php') ->setCategory('Test result file'); // Add some data $helper->log('Add some data'); $spreadsheet->setActiveSheetIndex(0) ->setCellValue('A1', 'Hello') ->setCellValue('B2', 'world!') ->setCellValue('C1', 'Hello') ->setCellValue('D2', 'world!'); // Miscellaneous glyphs, UTF-8 $spreadsheet->setActiveSheetIndex(0) ->setCellValue('A4', 'Miscellaneous glyphs') ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç'); $spreadsheet->getActiveSheet() ->setCellValue('A8', "Hello\nWorld"); $spreadsheet->getActiveSheet() ->getRowDimension(8) ->setRowHeight(-1); $spreadsheet->getActiveSheet() ->getStyle('A8') ->getAlignment() ->setWrapText(true); $value = "-ValueA\n-Value B\n-Value C"; $spreadsheet->getActiveSheet() ->setCellValue('A10', $value); $spreadsheet->getActiveSheet() ->getRowDimension(10) ->setRowHeight(-1); $spreadsheet->getActiveSheet() ->getStyle('A10') ->getAlignment() ->setWrapText(true); $spreadsheet->getActiveSheet() ->getStyle('A10') ->setQuotePrefix(true); // Rename worksheet $helper->log('Rename worksheet'); $spreadsheet->getActiveSheet() ->setTitle('Simple'); // Save $helper->write($spreadsheet, __FILE__, ['Xlsx', 'Xls', 'Ods']);
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Basic/08_Conditional_formatting_2.php
samples/Basic/08_Conditional_formatting_2.php
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Color; use PhpOffice\PhpSpreadsheet\Style\Conditional; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ // Create new Spreadsheet object $helper->log('Create new Spreadsheet object'); $spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); $spreadsheet->getProperties()->setCreator('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw') ->setTitle('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setKeywords('office 2007 openxml php') ->setCategory('Test result file'); // Create a first sheet, representing sales data $helper->log('Add some data'); $spreadsheet->setActiveSheetIndex(0); $spreadsheet->getActiveSheet() ->setCellValue('A1', '-0.5') ->setCellValue('A2', '-0.25') ->setCellValue('A3', '0.0') ->setCellValue('A4', '0.25') ->setCellValue('A5', '0.5') ->setCellValue('A6', '0.75') ->setCellValue('A7', '1.0') ->setCellValue('A8', '1.25'); $spreadsheet->getActiveSheet()->getStyle('A1:A8') ->getNumberFormat() ->setFormatCode( NumberFormat::FORMAT_PERCENTAGE_00 ); // Add conditional formatting $helper->log('Add conditional formatting'); $conditional1 = new Conditional(); $conditional1->setConditionType(Conditional::CONDITION_CELLIS) ->setOperatorType(Conditional::OPERATOR_LESSTHAN) ->addCondition('0'); $conditional1->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_RED); $conditional3 = new Conditional(); $conditional3->setConditionType(Conditional::CONDITION_CELLIS) ->setOperatorType(Conditional::OPERATOR_GREATERTHANOREQUAL) ->addCondition('1'); $conditional3->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_GREEN); $conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('A1')->getConditionalStyles(); $conditionalStyles[] = $conditional1; $conditionalStyles[] = $conditional3; $spreadsheet->getActiveSheet()->getStyle('A1')->setConditionalStyles($conditionalStyles); // duplicate the conditional styles across a range of cells $helper->log('Duplicate the conditional formatting across a range of cells'); $spreadsheet->getActiveSheet()->duplicateConditionalStyle( $spreadsheet->getActiveSheet()->getStyle('A1')->getConditionalStyles(), 'A2:A8' ); // Save $helper->write($spreadsheet, __FILE__);
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Basic/06_Largescale.php
samples/Basic/06_Largescale.php
<?php require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Spreadsheet */ $spreadsheet = require __DIR__ . '/../templates/largeSpreadsheet.php'; // Save /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ $helper->write($spreadsheet, __FILE__);
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false
PHPOffice/PhpSpreadsheet
https://github.com/PHPOffice/PhpSpreadsheet/blob/e33834b4ea2a02088becbb41fb8954d915b46b12/samples/Basic/02_Types.php
samples/Basic/02_Types.php
<?php use PhpOffice\PhpSpreadsheet\Cell\DataType; use PhpOffice\PhpSpreadsheet\RichText\RichText; use PhpOffice\PhpSpreadsheet\Shared\Date; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Color; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; require __DIR__ . '/../Header.php'; /** @var PhpOffice\PhpSpreadsheet\Helper\Sample $helper */ // Create new Spreadsheet object $helper->log('Create new Spreadsheet object'); $spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); $spreadsheet->getProperties() ->setCreator('Maarten Balliauw') ->setLastModifiedBy('Maarten Balliauw') ->setTitle('Office 2007 XLSX Test Document') ->setSubject('Office 2007 XLSX Test Document') ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.') ->setKeywords('office 2007 openxml php') ->setCategory('Test result file'); // Set default font $helper->log('Set default font'); $spreadsheet->getDefaultStyle() ->getFont() ->setName('Arial') ->setSize(10); // Add some data, resembling some different data types $helper->log('Add some data'); $spreadsheet->getActiveSheet() ->setCellValue('A1', 'String') ->setCellValue('B1', 'Simple') ->setCellValue('C1', 'PhpSpreadsheet'); $spreadsheet->getActiveSheet() ->setCellValue('A2', 'String') ->setCellValue('B2', 'Symbols') ->setCellValue('C2', '!+&=()~§±æþ'); $spreadsheet->getActiveSheet() ->setCellValue('A3', 'String') ->setCellValue('B3', 'UTF-8') ->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов'); $spreadsheet->getActiveSheet() ->setCellValue('A4', 'Number') ->setCellValue('B4', 'Integer') ->setCellValue('C4', 12); $spreadsheet->getActiveSheet() ->setCellValue('A5', 'Number') ->setCellValue('B5', 'Float') ->setCellValue('C5', 34.56); $spreadsheet->getActiveSheet() ->setCellValue('A6', 'Number') ->setCellValue('B6', 'Negative') ->setCellValue('C6', -7.89); $spreadsheet->getActiveSheet() ->setCellValue('A7', 'Boolean') ->setCellValue('B7', 'True') ->setCellValue('C7', true); $spreadsheet->getActiveSheet() ->setCellValue('A8', 'Boolean') ->setCellValue('B8', 'False') ->setCellValue('C8', false); $dateTimeNow = time(); $spreadsheet->getActiveSheet() ->setCellValue('A9', 'Date/Time') ->setCellValue('B9', 'Date') ->setCellValue('C9', Date::PHPToExcel($dateTimeNow)); $spreadsheet->getActiveSheet() ->getStyle('C9') ->getNumberFormat() ->setFormatCode(NumberFormat::FORMAT_DATE_YYYYMMDD); $spreadsheet->getActiveSheet() ->setCellValue('A10', 'Date/Time') ->setCellValue('B10', 'Time') ->setCellValue('C10', Date::PHPToExcel($dateTimeNow)); $spreadsheet->getActiveSheet() ->getStyle('C10') ->getNumberFormat() ->setFormatCode(NumberFormat::FORMAT_DATE_TIME4); $spreadsheet->getActiveSheet() ->setCellValue('A11', 'Date/Time') ->setCellValue('B11', 'Date and Time') ->setCellValue('C11', Date::PHPToExcel($dateTimeNow)); $spreadsheet->getActiveSheet() ->getStyle('C11') ->getNumberFormat() ->setFormatCode(NumberFormat::FORMAT_DATE_DATETIME); $spreadsheet->getActiveSheet() ->setCellValue('A12', 'NULL') ->setCellValue('C12', null); $richText = new RichText(); $richText->createText('你好 '); $payable = $richText->createTextRun('你 好 吗?'); $payable->getFontOrThrow()->setBold(true); $payable->getFontOrThrow()->setItalic(true); $payable->getFontOrThrow()->setColor(new Color(Color::COLOR_DARKGREEN)); $richText->createText(', unless specified otherwise on the invoice.'); $spreadsheet->getActiveSheet() ->setCellValue('A13', 'Rich Text') ->setCellValue('C13', $richText); $richText2 = new RichText(); $richText2->createText("black text\n"); $red = $richText2->createTextRun('red text'); $red->getFontOrThrow()->setColor(new Color(Color::COLOR_RED)); $spreadsheet->getActiveSheet() ->getCell('C14') ->setValue($richText2); $spreadsheet->getActiveSheet() ->getStyle('C14') ->getAlignment()->setWrapText(true); $spreadsheet->getActiveSheet()->setCellValue('A17', 'Hyperlink'); $spreadsheet->getActiveSheet() ->setCellValue('C17', 'PhpSpreadsheet Web Site'); $spreadsheet->getActiveSheet() ->getCell('C17') ->getHyperlink() ->setUrl('https://github.com/PHPOffice/PhpSpreadsheet') ->setTooltip('Navigate to PhpSpreadsheet website'); $spreadsheet->getActiveSheet()->getStyle('C17')->getFont()->setHyperlinkTheme(); $spreadsheet->getActiveSheet() ->setCellValue('C18', '=HYPERLINK("mailto:abc@def.com","abc@def.com")'); $spreadsheet->getActiveSheet()->getStyle('C18')->getFont()->setHyperlinkTheme(); $spreadsheet->getActiveSheet() ->setCellValue('A20', 'String') ->setCellValue('B20', 'inline') ->setCellValueExplicit('C20', 'This will not be added to sharedStrings.xml', DataType::TYPE_INLINE); $spreadsheet->getActiveSheet() ->getColumnDimension('B') ->setAutoSize(true); $spreadsheet->getActiveSheet() ->getColumnDimension('C') ->setAutoSize(true); // Rename worksheet $helper->log('Rename worksheet'); $spreadsheet->getActiveSheet()->setTitle('Datatypes'); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $spreadsheet->setActiveSheetIndex(0); // Save $helper->write($spreadsheet, __FILE__);
php
MIT
e33834b4ea2a02088becbb41fb8954d915b46b12
2026-01-04T15:02:44.305364Z
false