Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Lozza's avatar
Level 4

"spatie/simple-excel" Excel import/export

I am looking to export data to an excel spreadsheet and had some dificulties implementing maatwebsite/excel which I have seen mentioned on this forum. I then tried installing spatie/simple-excel which seems to install and work great.

With my limited experience of installing packages I just wanted to ask if this is a safe package for me to be installing on a live laravel release?

Thank you Lozza

0 likes
7 replies
LaryAI's avatar
Level 58

Spatie/Simple-Excel is a safe package to use in a live Laravel release. It is a lightweight package that provides a simple and intuitive API for importing and exporting Excel files. It is actively maintained by the Spatie team and has a good reputation in the Laravel community.

To export data to an Excel spreadsheet using Spatie/Simple-Excel, you can follow these steps:

  1. Install the package via Composer:
composer require spatie/simple-excel
  1. Use the SimpleExcelWriter class to create an Excel file and write data to it. Here's an example:
use Spatie\SimpleExcel\SimpleExcelWriter;

// Create a new Excel file
$excel = SimpleExcelWriter::create('path/to/file.xlsx');

// Add data to the file
$excel->addRow(['Name', 'Email']);
$excel->addRow(['John Doe', '[email protected]']);
$excel->addRow(['Jane Smith', '[email protected]']);

// Save the file
$excel->save();
  1. To import data from an Excel file, you can use the SimpleExcelReader class. Here's an example:
use Spatie\SimpleExcel\SimpleExcelReader;

// Read data from an Excel file
$excel = SimpleExcelReader::open('path/to/file.xlsx');

// Iterate over each row
foreach ($excel->getRows() as $row) {
    $name = $row['Name'];
    $email = $row['Email'];

    // Process the data as needed
    // ...
}

Remember to replace 'path/to/file.xlsx' with the actual path to your Excel file.

Overall, Spatie/Simple-Excel is a reliable package for Excel import/export in Laravel. It provides a straightforward API and should meet your needs for exporting data to an Excel spreadsheet.

Lozza's avatar
Level 4

@krisi_gjika I mean in the same way that I would run a virus check on an executable and check the reputation of the author before installing on a windows PC.

Snapey's avatar
Snapey
Best Answer
Level 122

@Lozza you have to go by the reputation of the project. How long has it been around? Is it well maintained? Does it have a lot of stars /downloads.

Generally speaking open source packages are trusted because you and others can see all the code.

https://packagist.org/packages/spatie/simple-excel

  • stars: 928
  • installs 2 million
  • 41 releases, last in March 23

Built by well respected agency https://spatie.be/open-source?search=&sort=-downloads with over 615 million downloads of its packages

So probably safer than ANYTHING you might install in Windows

1 like
Lozza's avatar
Level 4

@Snapey I didn't know about the packagist website... that helps a lot, thanks! :)

1 like
Snapey's avatar

@Lozza its where you go to find packages , and where composer gets all its information from

1 like

Please or to participate in this conversation.