Generate Excel XLSX Files via Open Source PHP Library
Open Source Free PHP Library to Generate Excel XLSX Files. Explore Features Like Styling, Formulas, Multiple Sheets, Merged Cells, and Array Exports with Code Examples.
What is SimpleXLSXGen?
In the world of PHP development, generating Excel files often means dealing with heavyweight libraries, complicated dependencies, and memory-hungry processes. Enter SimpleXLSXGen – a breath of fresh air for developers who need a straightforward, efficient solution for creating XLSX files. This open-source PHP library, created by Sergey Shuchkin, allows you to export data to Excel without requiring any external tools, extensions, or complex configurations. Whether you're building a reporting system, an e-commerce export feature, or a data migration tool, SimpleXLSXGen delivers professional results with minimal code.
Unlike bulky spreadsheet libraries, SimpleXLSXGen focuses on simplicity. You can create spreadsheets directly from arrays, style cells, merge cells, add formulas, and even create multiple sheets—all with clean PHP syntax. This makes it highly useful for reporting dashboards, invoice generation, exporting database records, financial statements, product catalogs, user data exports and so on. It handles UTF-8 encoding seamlessly, supports multiple worksheets, offers extensive formatting options through HTML-like tags, and can output files for download or save them directly to disk. The library is particularly valuable for shared hosting environments where installing additional extensions might not be possible, and its memory-efficient design means it can handle reasonably large datasets without crashing.
Getting Started with SimpleXLSXGen
The recommended way to install SimpleXLSXGen into your project is by using the composer. Please use the following command for a smooth installation.
Install SimpleXLSXGen via Composer:
composer require shuchkin/simplexlsxgenInstall SimpleXLSXGen via Git
gh repo clone mk-j/SimpleXLSXGenCreate Excel Files from Arrays via PHP API
One of the best features of SimpleXLSXGen is its ability to instantly convert PHP arrays into Excel files. This is ideal when exporting database query results, API responses, or user-generated content. Instead of manually building spreadsheets cell by cell, developers can simply pass an array and save the file. The following example shows how the library helps to dramatically reduces development time when exporting tabular data.
How to Rapidly Export Tabular Data into Excel File via PHP Library?
use Shuchkin\SimpleXLSXGen;
$data = [
['ID', 'Name', 'Email'],
[1, 'John Doe', 'john@example.com'],
[2, 'Jane Smith', 'jane@example.com']
];
SimpleXLSXGen::fromArray($data)
->saveAs('users.xlsx');
Manage Multiple Worksheets in One File via PHP
The open source SimpleXLSXGen library lets developers create multiple sheets inside a single workbook, which is essential for organizing large datasets. It supports features like adding new worksheets, editing existing sheets, delete unwanted sheets and so on. It all creating monthly reports, department sheets or regional sales data with ease. The library Keeps related information neatly organized in one downloadable file. The following example shows how to create various types of reports while working with multiple worksheets.
How to Create Various Types of Sales Reports in Excel Sheets using PHP Library?
$xlsx = SimpleXLSXGen::fromArray([
['January Sales', 5000]
]);
$xlsx->addSheet([
['February Sales', 7000]
], 'February');
$xlsx->saveAs('reports.xlsx');
HTML-Style Formatting Without Complexity
SimpleXLSXGen revolutionizes Excel styling by allowing you to use familiar HTML tags directly within your cell values. You can apply bold, italic, underline, colors, fonts, alignment, borders, and even background colors using simple markup like , ,