Export data to Excel. PHP XLSX generator
Export data to Excel XLSX file. PHP XLSX generator. No external tools and libraries.
Sergey Shuchkin 2020-2025
Hey, bro, please ★ the package for my motivation :) and donate for more motivation!
$books = [
['ISBN', 'title', 'author', 'publisher', 'ctry' ],
[618260307, 'The Hobbit', 'J. R. R. Tolkien', 'Houghton Mifflin', 'USA'],
[908606664, 'Slinky Malinki', 'Lynley Dodd', 'Mallinson Rendel', 'NZ']
];
$xlsx = Shuchkin\SimpleXLSXGen::fromArray( $books );
$xlsx->saveAs('books.xlsx'); // or downloadAs('books.xlsx') or $xlsx_content = (string) $xlsx The recommended way to install this library is through Composer. New to Composer?
This will install the latest supported version:
$ composer require shuchkin/simplexlsxgenor download class here
Use UTF-8 encoded strings.
……Prefix #0 cell value (use double quotes) or use ::raw() ::rawArray() methods or tag ``````
$PushkinDOB = '1799-07-06';
$data = [
['Datetime as raw string', "\0" . '2023-01-09 11:16:34'],
['Date as raw string', "\0" . $PushkinDOB],
['Disable type detection', "\0" . '+12345'],
['Method ::raw, insert greater/less them simbols', SimpleXLSXGen::raw('20- short term: +123456 <tag>'],
];
SimpleXLSXGen::fromArray($data)
->saveAs('test_rawstrings.xlsx');
$data = [
['test', 'raw', 'array'],
['2025-08-09 14:36:34', '', 1]
];
$raw_data = SimpleXLSXGen::rawArray($data);
SimpleXLSXGen::fromArray($raw_data)->saveAs('test_raw_array.xlsx');…downloadAs('file.xlsx');
return;
}
?>
JS array to Excel
ini_set('error_reporting', E_ALL );
ini_set('display_errors', 1 );
$data = [
['Debug', 123]
];
Shuchkin\SimpleXLSXGen::fromArray( $data )->saveAs('debug.xlsx');No open issues yet, or sync has not completed.