Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Datatables Export

Laravel Datatables Export Laravel Package

yajra/laravel-datatables-export

Laravel DataTables export plugin for server-side exporting via queued jobs, OpenSpout, and Livewire. Adds an export button component and DataTable trait (WithExportQueue) to generate Excel/CSV exports for jQuery DataTables 2.x on Laravel 13.

View on GitHub
Deep Wiki
Context7

yajra/laravel-datatables-export is an export plugin for Laravel DataTables that adds scalable, server-side exporting powered by Queues, OpenSpout, and Livewire. It’s designed for DataTables apps that need reliable exports without blocking requests, even for large datasets.

Integrate an export button component in your views and enable queued exporting in your DataTable class to generate files asynchronously and keep your UI responsive.

Features

  • Queued, server-side exports for large tables
  • Livewire export button component for easy UI integration
  • OpenSpout-based output for efficient spreadsheet generation
  • Works seamlessly with Laravel DataTables 13.x and jQuery DataTables 2.x
  • Supports batch jobs via Laravel’s queue batches table
Frequently asked questions about Laravel Datatables Export
How do I add an export button to my existing Laravel DataTables view?
Use the `<livewire:export-button>` component in your Blade view, passing the DataTable’s ID via `:table-id`. Ensure your DataTable class extends `WithExportQueue` to enable queued exports. Example: `<livewire:export-button :table-id="$dataTable->getTableId()"/>`.
What Laravel and PHP versions does this package support?
This package requires **Laravel 13.x** and **PHP 8.3+** (PHP 8.4+ for OpenSpout 5.x). If you’re on Laravel 10/11, you’ll need to upgrade to Laravel 13. Check the [compatibility table](https://github.com/yajra/laravel-datatables-export) for older versions.
Do I need Livewire for exports? What if I don’t use Livewire?
Yes, this package **requires Livewire** for the export button component. If you’re not using Livewire, you’ll need to create a custom Blade component or AJAX endpoint to trigger exports via a controller, bypassing the Livewire dependency.
How do I handle large datasets (e.g., 50K+ rows) without memory issues?
The package uses **OpenSpout** for efficient streaming exports and **queued jobs** to avoid blocking requests. For very large datasets, configure chunking in your query (e.g., `->chunk(1000)`) and ensure your queue worker has sufficient memory. Monitor disk space if storing files locally.
What queue drivers are supported, and how do I set up workers?
Supported drivers include **Redis, database, and SQS**. Run `php artisan queue:work` to start workers. For high-volume exports, use Redis or a dedicated queue service. Ensure the `queue:batches-table` migration is run (`php artisan queue:batches-table && php artisan migrate`).
Can I export to formats other than CSV/XLSX, or is it limited to OpenSpout?
This package **only supports CSV and XLSX** via OpenSpout. If you need PDFs or other formats, consider integrating a separate library like **Barryvdh/Laravel-Snappy** or **Dompdf** alongside this package for hybrid workflows.
How do I store exported files on S3 instead of local disk?
Configure the `tmp_path` in `config/datatables-export.php` to point to an S3-compatible storage disk (e.g., `tmp_path => 's3://your-bucket/exports'`). Ensure your storage driver is properly set up in `config/filesystems.php` and the IAM role has write permissions.
What happens if the queue fails during an export? Can I retry or fallback to sync?
Failed jobs are retried automatically by Laravel’s queue system. For critical exports, implement a **fallback sync method** by extending the `ExportQueue` class or using a middleware to catch failures. Log errors via `Log::error()` for debugging.
How do I notify users when their export is ready (e.g., email or Livewire toast)?
Use Livewire’s `emit()` to show a toast notification when the export job completes. For emails, dispatch a `Mailable` in the job’s `handle()` method. Example: `ExportJob::dispatch($dataTable)->onQueue('exports');` then listen for job completion in Livewire.
Are there performance benchmarks for complex queries (e.g., joins, aggregations)?
Performance depends on your database and query complexity. Test with your actual data using `tntsearch/laravel-scout-tnt` for large datasets or optimize queries with indexes. For joins, consider denormalizing or caching results if exports run frequently.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport