New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

kriss/data-export

Data Export For PHP
1,703 2
Install
composer require kriss/data-export
Latest Version:v2.1.0
PHP:^8.1
Laravel:9 · 10 · 11
Older releases:5 – 8
License:MIT
Last Updated:Oct 14, 2025
Links: GitHub  ·  Packagist
Maintainer: kriss

Data Export For PHP

Latest Version on Packagist Tests Total Downloads

Wrap sonata-project/exporter, make it easy and strong~

Feature

  • Simple api (use DataExporter::csv()->saveAs())
  • Quick change for different output type (csv/xlsx/xls/ods...)
  • Support a lot of source, and can use array or iterator quickly
  • Low memory usage with huge data write (use csv/xlsxSpout)
  • Low memory usage with chunk data fetch and write by chain (use GeneratorChainSourceIterator)
  • Support saveAs() and browserDownload()
  • Support do something in writing (use ObjectEvent)
  • Support control Spreadsheet and Spout Instance, for change style and others (use Extend)
  • Support Excel multi sheet write (use ExcelSheetSourceIterator)
  • Support Dynamic source (use CallableSourceIterator)

Installation

You can install the package via composer:

composer require kriss/data-export

Usage

simple Example

use \Kriss\DataExporter\DataExporter;

$source = [
    ['aaa', 'bbb', 'ccc'],
    ['aaa', 'bbb', 'ccc'],
    ['aaa', 'bbb', 'ccc'],
];
DataExporter::csv($source, ['showHeaders' => false])->saveAs();

Support Source

Support Writer

All Config in DataExporter::writerConfig(), see Tests

You can extend DataExporter and add Yours, see Example in Tests

FAQ

Why box/spout Use

box/spout can write xlsx use stream, but phpoffice/phpspreadsheet not. phpoffice/phpspreadsheet use lots of memory when write huge data, but box/spout use few!

When use GeneratorChainSourceIterator

When you should handle huge source and need to merge them in one write.

How to build style

Use extension, see ExtendSpoutTest or ExtendSpreadsheetTest

How to write multi sheet

Use ExcelSheetSpreadsheetTrait, see ExcelSheetSourceIteratorTest

Related Packages

goldnead/statamic-accounts

Accounts for Statamic: email verification, email change with confirmation, accou...

1,015 0
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

651,963,193 9,701
laravel/framework

The Laravel Framework.

610,364,751 34,988
laravel/tinker

Powerful REPL for the Laravel framework.

518,004,183 7,444
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

435,097,283 607

Version History

Version Released PHP Laravel License
v2.1.0 ^8.1 >=9 MIT
v2.0.0 ^8.1 >=9 MIT
v1.11.0 ^7.3|^8.0 >=6 MIT
v1.10.0 ^7.3 >=6 MIT
v1.9.0 ^7.3 >=6 MIT