Convert Figma logo to code with AI

SpartnerNL logoLaravel-Excel

🚀 Supercharged Excel exports and imports in Laravel

12,219
1,906
12,219
17

Top Related Projects

🚀 Supercharged Excel exports and imports in Laravel

🦉 Fast Excel import/export for Laravel

A pure PHP library for reading and writing spreadsheet files

4,220

Read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

A Python module for creating Excel XLSX files.

Quick Overview

Laravel-Excel is a powerful and feature-rich package for importing and exporting Excel and CSV files in Laravel applications. It provides a simple and intuitive API for handling spreadsheet operations, making it easy to integrate Excel functionality into Laravel projects.

Pros

  • Seamless integration with Laravel's Eloquent ORM for easy data manipulation
  • Support for various file formats including XLSX, CSV, and TSV
  • Efficient handling of large datasets through chunking and queuing
  • Extensive customization options for styling and formatting exports

Cons

  • Learning curve for advanced features and configurations
  • Performance can be impacted when dealing with extremely large files
  • Limited support for complex Excel formulas and macros
  • Dependency on the PhpSpreadsheet library, which may introduce compatibility issues

Code Examples

  1. Basic Excel export:
use App\Exports\UsersExport;
use Maatwebsite\Excel\Facades\Excel;

return Excel::download(new UsersExport, 'users.xlsx');
  1. Importing Excel data:
use App\Imports\UsersImport;
use Maatwebsite\Excel\Facades\Excel;

Excel::import(new UsersImport, 'users.xlsx');
  1. Exporting with custom styling:
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

class UsersExport implements WithStyles
{
    public function styles(Worksheet $sheet)
    {
        return [
            1 => ['font' => ['bold' => true]],
        ];
    }
}

Getting Started

  1. Install the package via Composer:
composer require maatwebsite/excel
  1. Add the service provider to config/app.php:
'providers' => [
    // ...
    Maatwebsite\Excel\ExcelServiceProvider::class,
]
  1. Add the facade to config/app.php:
'aliases' => [
    // ...
    'Excel' => Maatwebsite\Excel\Facades\Excel::class,
]
  1. Publish the configuration file:
php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config

Now you're ready to use Laravel-Excel in your Laravel application!

Competitor Comparisons

🚀 Supercharged Excel exports and imports in Laravel

Pros of Laravel-Excel

  • Seamless integration with Laravel framework
  • Supports both importing and exporting of Excel files
  • Extensive documentation and community support

Cons of Laravel-Excel

  • Performance can be slower for large datasets
  • Limited customization options for complex Excel operations
  • Steeper learning curve for advanced features

Code Comparison

Laravel-Excel:

use Maatwebsite\Excel\Facades\Excel;

Excel::download(new UsersExport, 'users.xlsx');

Laravel-Excel:

use Maatwebsite\Excel\Facades\Excel;

Excel::download(new UsersExport, 'users.xlsx');

As you can see, the code comparison shows identical usage for both repositories. This is because Laravel-Excel is being compared to itself in this scenario. In a real-world comparison between two different libraries, you would typically see differences in syntax, method names, or overall approach to handling Excel operations.

The Laravel-Excel package is a popular choice for Laravel developers who need to work with Excel files. It offers a straightforward API for importing and exporting data, making it easy to integrate Excel functionality into Laravel applications. However, for more complex Excel manipulations or when dealing with very large datasets, developers might need to consider alternative solutions or implement custom optimizations.

🦉 Fast Excel import/export for Laravel

Pros of Fast-Excel

  • Significantly faster performance for large datasets
  • Lower memory usage, especially for big files
  • Simpler API with fewer dependencies

Cons of Fast-Excel

  • Less feature-rich compared to Laravel-Excel
  • Limited support for complex Excel operations
  • Fewer options for customization and formatting

Code Comparison

Fast-Excel:

$users = User::all();
(new FastExcel($users))->export('users.xlsx');

Laravel-Excel:

Excel::create('users', function($excel) use($users) {
    $excel->sheet('Sheet 1', function($sheet) use($users) {
        $sheet->fromModel($users);
    });
})->export('xlsx');

Fast-Excel focuses on simplicity and performance, making it ideal for basic export/import tasks with large datasets. Laravel-Excel offers more advanced features and greater flexibility, but at the cost of increased complexity and resource usage. The choice between the two depends on the specific requirements of your project, balancing speed and simplicity against feature richness and customization options.

A pure PHP library for reading and writing spreadsheet files

Pros of PhpSpreadsheet

  • More versatile and can be used in any PHP project, not limited to Laravel
  • Supports a wider range of file formats, including ODS and XLSX
  • More comprehensive documentation and community support

Cons of PhpSpreadsheet

  • Steeper learning curve, especially for Laravel developers
  • Requires more boilerplate code for basic operations
  • Less integration with Laravel-specific features

Code Comparison

Laravel-Excel:

use Maatwebsite\Excel\Facades\Excel;

Excel::download(new UsersExport, 'users.xlsx');

PhpSpreadsheet:

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');

$writer = new Xlsx($spreadsheet);
$writer->save('hello world.xlsx');

Laravel-Excel provides a more concise and Laravel-friendly syntax, while PhpSpreadsheet offers more granular control but requires more setup code. Laravel-Excel is better suited for quick Excel operations in Laravel applications, whereas PhpSpreadsheet is more powerful for complex spreadsheet manipulations across various PHP projects.

4,220

Read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

Pros of Spout

  • Lightweight and memory-efficient, suitable for handling large files
  • Framework-agnostic, can be used in any PHP project
  • Simple API for reading and writing spreadsheets

Cons of Spout

  • Limited formatting options compared to Laravel-Excel
  • Lacks some advanced features like cell styling and formula support
  • No built-in Laravel integration (requires additional setup)

Code Comparison

Laravel-Excel:

use Maatwebsite\Excel\Facades\Excel;

Excel::download(new UsersExport, 'users.xlsx');

Spout:

use Box\Spout\Writer\Common\Creator\WriterEntityFactory;

$writer = WriterEntityFactory::createXLSXWriter();
$writer->openToFile($filePath);
$writer->addRow(WriterEntityFactory::createRowFromArray($rowData));
$writer->close();

Summary

Laravel-Excel is a feature-rich package specifically designed for Laravel, offering extensive formatting options and seamless integration. Spout, on the other hand, is a lightweight, memory-efficient library that excels at handling large files across various PHP projects. While Laravel-Excel provides a more convenient API for Laravel developers, Spout offers better performance for processing substantial datasets. The choice between the two depends on project requirements, file sizes, and whether Laravel integration is necessary.

A Python module for creating Excel XLSX files.

Pros of XlsxWriter

  • Lightweight and focused solely on Excel file creation
  • Supports a wider range of Excel features and formatting options
  • Can be used in various Python environments, not limited to Laravel

Cons of XlsxWriter

  • Requires more manual configuration and setup
  • Lacks built-in integration with Laravel's Eloquent ORM
  • May require additional code for handling large datasets efficiently

Code Comparison

XlsxWriter:

import xlsxwriter

workbook = xlsxwriter.Workbook('example.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write('A1', 'Hello Excel!')
workbook.close()

Laravel-Excel:

use Maatwebsite\Excel\Facades\Excel;
use App\Exports\UsersExport;

Excel::download(new UsersExport, 'users.xlsx');

XlsxWriter provides a more low-level approach, giving developers fine-grained control over Excel file creation. It requires explicit workbook and worksheet creation, as well as manual cell writing.

Laravel-Excel, on the other hand, offers a higher-level abstraction, leveraging Laravel's ecosystem. It simplifies the export process by using export classes and integrating seamlessly with Eloquent models.

While XlsxWriter offers more flexibility and Excel-specific features, Laravel-Excel provides a more streamlined experience for Laravel developers, especially when working with database-driven exports.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README



Laravel Excel logo


Supercharged Excel exports and imports

A simple, but elegant Laravel wrapper around PhpSpreadsheet exports and imports.

Quickstart · Documentation · Video Course · Nova · Blog · Contributing · Support

Github Actions StyleCI Latest Stable Version Total Downloads License

✨ Features

  • Easily export collections to Excel. Supercharge your Laravel collections and export them directly to an Excel or CSV document. Exporting has never been so easy.

  • Supercharged exports. Export queries with automatic chunking for better performance. You provide us the query, we handle the performance. Exporting even larger datasets? No worries, Laravel Excel has your back. You can queue your exports so all of this happens in the background.

  • Supercharged imports. Import workbooks and worksheets to Eloquent models with chunk reading and batch inserts! Have large files? You can queue every chunk of a file! Your entire import will happen in the background.

  • Export Blade views. Want to have a custom layout in your spreadsheet? Use a HTML table in a Blade view and export that to Excel.

banner

🎓 Learning Laravel Excel

You can find the full documentation of Laravel Excel on the website.

We welcome suggestions for improving our docs. The documentation repository can be found at https://github.com/SpartnerNL/laravel-excel-docs.

Some articles and tutorials can be found on our blog: https://medium.com/maatwebsite/laravel-excel/home

:mailbox_with_mail: License & Postcardware

1_5nblgs68uarg0wxxejozdq

Laravel Excel is created with love and care by Spartner (formerly known as Maatwebsite) to give back to the Laravel community. It is completely free (MIT license) to use, however the package is licensed as Postcardware. This means that if it makes it to your production environment, we would very much appreciate receiving a postcard from your hometown.

Spartner Markt 2 6231 LS Meerssen The Netherlands.

More about the license can be found at: https://docs.laravel-excel.com/3.1/getting-started/license.html

Created by Spartner (formerly Maatwebsite)

We are a strategic development partner, creating web-based custom built software from Laravel. In need of a digital solution for your challenge? Give us a call.

https://spartner.software info@spartner.nl +31 (0) 10 - 7449312

:wrench: Supported Versions

Versions will be supported for a limited amount of time.

VersionLaravel VersionPhp VersionSupport
2.1<=5.6<=7.0Unsupported since 15-5-2018
3.0^5.5^7.0Unsupported since 31-12-2018
3.1>=5.8 | <=11.x^7.2 | ^8.0New features