{"id":16674825,"url":"https://github.com/odan/excel","last_synced_at":"2026-03-15T19:39:23.800Z","repository":{"id":206302931,"uuid":"715339528","full_name":"odan/excel","owner":"odan","description":"Extreme fast, in-memory Excel (XLSX) file writer.","archived":false,"fork":false,"pushed_at":"2025-11-15T17:37:15.000Z","size":71,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-26T08:34:58.773Z","etag":null,"topics":["excel","excel-export","php","xlsx"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/odan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-11-07T00:11:56.000Z","updated_at":"2025-11-15T17:36:01.000Z","dependencies_parsed_at":"2023-11-08T23:24:24.136Z","dependency_job_id":"88da708e-acaa-4b2e-a283-cd0dad5b1ea8","html_url":"https://github.com/odan/excel","commit_stats":null,"previous_names":["odan/excel"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/odan/excel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odan%2Fexcel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odan%2Fexcel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odan%2Fexcel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odan%2Fexcel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/odan","download_url":"https://codeload.github.com/odan/excel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odan%2Fexcel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30550482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-15T15:03:43.933Z","status":"ssl_error","status_checked_at":"2026-03-15T15:03:37.630Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["excel","excel-export","php","xlsx"],"created_at":"2024-10-12T12:44:31.309Z","updated_at":"2026-03-15T19:39:23.770Z","avatar_url":"https://github.com/odan.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# odan/excel\n\n[![Latest Version on Packagist](https://img.shields.io/github/release/odan/excel.svg)](https://github.com/odan/excel/releases)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)\n[![Build Status](https://github.com/odan/excel/workflows/build/badge.svg)](https://github.com/odan/excel/actions)\n[![Total Downloads](https://img.shields.io/packagist/dt/odan/excel.svg)](https://packagist.org/packages/odan/excel/stats)\n\nExtreme fast in-memory Excel (XLSX) file writer.\n\n## Requirements\n\n* PHP 8.1 - 8.5\n\n## Features\n\n- Optimized for minimal memory usage and high performance.\n- Compatibility with Microsoft Excel 2007-365 (ISO/IEC 29500-1:2016).\n- Compatibility with LibreOffice / OpenOffice Calc.\n- In-memory operation by default.\n- Optional hard disk access, when memory limitations are reached.\n- Multiple sheets in a workbook.\n- Header columns with bold font.\n- Custom worksheet name.\n- Data types for rows: string, int, float\n- Data types for columns: string\n\n## Limitations\n\nThe purpose of this package is to provide a very fast and\nmemory efficient Excel (XLSX) file generator. It is designed for\nvery fast data output, but not for fancy worksheet styles.\nIf you need more layout and color options, you may better use a\ndifferent package, such as PhpSpreadsheet.\n\n* Number of workbooks and sheets: Limited by available memory and system resources.\n* Maximal number of columns: 16.384 (specification limit)\n* Maximal number of rows: 1.048.576 (specification limit)\n* Font styles: 2 (normal for rows and **bold** for columns)\n\n## Installation\n\n```bash\ncomposer require odan/excel\n```\n\n## Usage\n\n```php\nuse Odan\\Excel\\ExcelWorkbook;\nuse Odan\\Excel\\ZipDeflateStream;\n\n$workbook = new ExcelWorkbook();\n$sheet = $workbook-\u003eaddSheet('My Sheet');\n\n// Write header columns\n$columns = ['Date', 'Name', 'Amount'];\n$sheet-\u003eaddColumns($columns);\n\n// Write data\n$rows = [\n    ['2023-01-31', 'James', 220],\n    ['2023-03-28', 'Mike', 153.5],\n    ['2024-07-02', 'Sally', 34.12],\n];\n\nforeach ($rows as $row) {\n    $sheet-\u003eaddRow($row);\n}\n\n// Save as Excel file in memory\n$file = new ZipDeflateStream();\n$workbook-\u003esave($file);\n```\n\n**Generating only In-Memory Excel file**\n\nThis data is a pure in-memory stream `php://memory` (default)\nthat never overflows onto the hard disk, \nregardless of the amount of written data.\n\n```php\nuse Odan\\Excel\\ZipDeflateStream;\n\n// ...\n\n$file = new ZipDeflateStream();\n$workbook-\u003esave($file);\n```\n\n**Generating temporary files**\n\nThe `php://temp` stream is designed for temporary data storage in memory.\n\nHowever, if the amount of data written exceeds a certain threshold \n(usually around 2KB or 8KB, depending on PHP versions and configurations), \nPHP may automatically switch to using temporary files on disk to store the data. \nThis is done to conserve memory when dealing with large amounts of data.\n\nThis kind of stream is suitable for most scenarios where you need temporary \nin-memory storage, but it should automatically switch to using temporary files \non disk to store the excess data when it overflows a certain threshold.\n\n```php\nuse Odan\\Excel\\ZipDeflateStream;\n\n// ...\n\n$file = new ZipDeflateStream('php://temp');\n$workbook-\u003esave($file);\n```\n\nThe memory limit of `php://temp` can be controlled by appending `/maxmemory:NN`,\nwhere NN is the maximum amount of data to keep in memory before using a temporary file, in bytes.\n\nThis optional parameter allows setting the memory limit before `php://temp` starts using a temporary file.\n\n```php\nuse Odan\\Excel\\ZipDeflateStream;\n\n// ...\n\n// Set the limit to 5 MB.\n$maxMb = 5 * 1024 * 1024;\n$file = new ZipDeflateStream('php://temp/maxmemory:' . $maxMb);\n$workbook-\u003esave($file);\n```\n\n**Save file in filesystem**\n\nIf the file does not exist, it will be created.\nIf it already exists, its content will be truncated (cleared)\nwhen you write data to it.\nMake sure the server has write permissions.\n\nDirectly as file stream...\n\n```php\nuse Odan\\Excel\\ZipDeflateStream;\n\n// ...\n\n$file = new ZipDeflateStream('example.xlsx');\n$workbook-\u003esave($file);\n```\n\n... or with stream_get_contents.\n\n```php\nuse Odan\\Excel\\ZipDeflateStream;\n\n// ...\n\n$file = new ZipDeflateStream();\n$workbook-\u003esave($file);\n\n$data = stream_get_contents($file-\u003egetStream());\nfile_put_contents('filename.xlsx', $data);\n```\n\n**Generating Excel file on hard disk with write permissions**\n\n```php\nuse Odan\\Excel\\ZipDeflateStream;\n\n// ...\n\n$filename = 'example.xlsx';\n\n// Create an empty file using touch\ntouch($filename);\n\n// Set write permissions to the file\nchmod($filename, 0644);\n\n$file = new ZipDeflateStream($filename);\n$workbook-\u003esave($file);\n```\n\n**Reading the stream contents as string**\n\n```php\nuse Odan\\Excel\\ZipDeflateStream;\n\n// ...\n\n$file = new ZipDeflateStream();\n$workbook-\u003esave($file);\n\n// Read contents of stream into a string\n$data = stream_get_contents($file-\u003egetStream());\n```\n\n**Stream directly to the HTTP response**\n\nTo send an existing stream directly to the HTTP response,\nyou can use the `fpassthru` function. This function reads from\nan open file pointer and sends the contents directly to the output buffer.\n\nHere's an example of how to do this:\n\n```php\n\u003c?php\n\n// Set the content type to Excel\nheader('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');\nheader('Content-Disposition: attachment; filename=\"example.xlsx\"');\n\n// ...\n$stream = $file-\u003egetStream();\n\n// Send the stream contents directly to the HTTP response\nfpassthru($stream);\n\n// Close the stream\nfclose($stream);\n```\n\n**Stream directly to the PSR-7 HTTP response**\n\nTo stream a file directly to an PSR-7 HTTP response using\nthe [Nyholm PSR-7](https://github.com/Nyholm/psr7) package, you may use it as follows:\n\n```php\nuse Nyholm\\Psr7\\Response;\nuse Nyholm\\Psr7\\Stream;\nuse Odan\\Excel\\ZipDeflateStream;\n\n// ...\n\n$file = new ZipDeflateStream();\n$workbook-\u003esave($file);\n\n// Generate safe filename\n$outputFilename = rawurlencode(basename('example.xlsx'));\n$contentDisposition = sprintf(\"attachment; filename*=UTF-8''%s\", $outputFilename);\n\n// Add the response headers\n$response = $response\n    -\u003ewithHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')\n    -\u003ewithHeader('Content-Disposition', $contentDisposition)\n    -\u003ewithHeader('Pragma', 'private')\n    -\u003ewithHeader('Cache-Control', 'private, must-revalidate')\n    -\u003ewithHeader('Content-Transfer-Encoding', 'binary');\n\n// Set the response body to the file stream\n$response = $response-\u003ewithBody(new Stream($file-\u003egetStream()));\n```\n\nChange the filename accordingly.\n\n## Using the ZipStream-PHP package\n\nWhen working with very large Excel files, typically over 4 GB, \nyou can use the [ZipStream-PHP](https://github.com/maennchen/ZipStream-PHP) package to \ncreate Excel files in the ZIP64 format, which is designed for handling such large files.\n\n**Installation**\n\n```bash\ncomposer require maennchen/zipstream-php\n```\n\nNext, use the `Odan\\Excel\\Zip64Stream` class for creating Excel \nfiles that offer improved compatibility and support larger file sizes.\n\n```php\nuse Odan\\Excel\\ExcelWorkbook;\nuse Odan\\Excel\\Zip64Stream;\n\n$workbook = new ExcelWorkbook();\n$sheet = $workbook-\u003eaddSheet('My Sheet');\n\n// Write data\n$rows = [\n    ['2023-01-31', 'James', 220],\n    ['2023-03-28', 'Mike', 153.5],\n    ['2024-07-02', 'Sally', 34.12],\n];\n\nforeach ($rows as $row) {\n    $sheet-\u003eaddRow($row);\n}\n\n// Save as Excel file\n$file = new Zip64Stream('filename.xlsx');\n$workbook-\u003esave($file);\n```\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodan%2Fexcel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fodan%2Fexcel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodan%2Fexcel/lists"}