Download the PHP package odan/excel without Composer
On this page you can find all versions of the php package odan/excel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package excel
Short Description In-memory Excel file writer
License MIT
Homepage https://github.com/odan/excel
Informations about the package excel
odan/excel
Extreme fast in-memory Excel (XLSX) file writer.
Requirements
- PHP 8.1+
Features
- Optimized for minimal memory usage and high performance.
- Compatibility with Microsoft Excel 2007-365 (ISO/IEC 29500-1:2016).
- Compatibility with LibreOffice / OpenOffice Calc.
- In-memory operation by default.
- Optional hard disk access, when memory limitations are reached.
- Multiple sheets in a workbook.
- Header columns with bold font.
- Custom worksheet name.
- Data types for rows: string, int, float
- Data types for columns: string
Limitations
The purpose of this package is to provide a very fast and memory efficient Excel (XLSX) file generator. It is designed for very fast data output, but not for fancy worksheet styles. If you need more layout and color options, you may better use a different package, such as PhpSpreadsheet.
- Number of workbooks and sheets: Limited by available memory and system resources.
- Maximal number of columns: 16.384 (specification limit)
- Maximal number of rows: 1.048.576 (specification limit)
- Font styles: 2 (normal for rows and bold for columns)
Installation
Usage
Generating only In-Memory Excel file
This data is a pure in-memory stream php://memory
(default)
that never overflows onto the hard disk,
regardless of the amount of written data.
Generating temporary files
The php://temp
stream is designed for temporary data storage in memory.
However, if the amount of data written exceeds a certain threshold (usually around 2KB or 8KB, depending on PHP versions and configurations), PHP may automatically switch to using temporary files on disk to store the data. This is done to conserve memory when dealing with large amounts of data.
This kind of stream is suitable for most scenarios where you need temporary in-memory storage, but it should automatically switch to using temporary files on disk to store the excess data when it overflows a certain threshold.
The memory limit of php://temp
can be controlled by appending /maxmemory:NN
,
where NN is the maximum amount of data to keep in memory before using a temporary file, in bytes.
This optional parameter allows setting the memory limit before php://temp
starts using a temporary file.
Save file in filesystem
If the file does not exist, it will be created. If it already exists, its content will be truncated (cleared) when you write data to it. Make sure the server has write permissions.
Directly as file stream...
... or with stream_get_contents.
Generating Excel file on hard disk with write permissions
Reading the stream contents as string
Stream directly to the HTTP response
To send an existing stream directly to the HTTP response,
you can use the fpassthru
function. This function reads from
an open file pointer and sends the contents directly to the output buffer.
Here's an example of how to do this:
Stream directly to the PSR-7 HTTP response
To stream a file directly to an PSR-7 HTTP response using the Nyholm PSR-7 package, you may use it as follows:
Change the filename accordingly.
Using the ZipStream-PHP package
When working with very large Excel files, typically over 4 GB, you can use the ZipStream-PHP package to create Excel files in the ZIP64 format, which is designed for handling such large files.
Installation
Next, use the Odan\Excel\Zip64Stream
class for creating Excel
files that offer improved compatibility and support larger file sizes.
License
The MIT License (MIT). Please see License File for more information.
All versions of excel with dependencies
ext-dom Version *
ext-zlib Version *