PHPackages                             fersot/excel-to - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fersot/excel-to

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

fersot/excel-to
===============

Laravel package that converts Excel/CSV files to JSON, Collection, or Array — with fluent API, sheet selection, column filtering, and export support.

v2.0.0(3mo ago)1261MITPHPPHP ^8.1

Since Oct 13Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/fersot/excel-to)[ Packagist](https://packagist.org/packages/fersot/excel-to)[ Docs](https://github.com/fersot/excel-to)[ RSS](/packages/fersot-excel-to/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (6)Versions (3)Used By (1)

Laravel Excel to JSON / Collection / Array
==========================================

[](#laravel-excel-to-json--collection--array)

A Laravel package for converting **Excel** and **CSV** files to JSON, Laravel Collections, or PHP Arrays — with a fluent API, multi-sheet support, column filtering, date formatting, and export capabilities.

[![Latest Version](https://camo.githubusercontent.com/1e0140c064e64ea67d3600bde2d7a00a0864684be55bb204836470c6d83507b3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666572736f742f657863656c2d746f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fersot/excel-to)[![PHP Version](https://camo.githubusercontent.com/ee631d1b3535e8b3a99c9152d465e9db0c74b77d6c84694515f8ebc38cda9aea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c75653f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fersot/excel-to)[![License](https://camo.githubusercontent.com/422db9fd40f5831c765cf6530b6750c081b696bd18d904cf89554df98c676277/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e3f7374796c653d666c61742d737175617265)](LICENSE)[![Tests](https://camo.githubusercontent.com/ede96cd474aad664926f0733df7c92261bd199e5430c73e09efe0a39664051fc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d323525323070617373696e672d627269676874677265656e3f7374796c653d666c61742d737175617265)](#)

Installation
------------

[](#installation)

```
composer require fersot/excel-to
```

Laravel auto-discovers the service provider and facade automatically.

Optionally publish the config file:

```
php artisan vendor:publish --tag=excel-to-config
```

---

Quick Start
-----------

[](#quick-start)

```
use Fersot\ExcelTo\ExcelTo;

// Static shortcuts (backwards compatible)
$array      = ExcelTo::array('path/to/file.xlsx');
$collection = ExcelTo::collection('path/to/file.xlsx');
$json       = ExcelTo::json('path/to/file.xlsx');

// Fluent API (recommended)
$data = ExcelTo::file('path/to/file.xlsx')
    ->sheet('Clientes')
    ->skipEmpty()
    ->only(['nombre', 'email', 'ciudad'])
    ->dateFormat('Y-m-d')
    ->toArray();
```

---

Reading Files
-------------

[](#reading-files)

### Load from path

[](#load-from-path)

```
ExcelTo::file('path/to/file.xlsx')->toArray();
```

### Load from Laravel UploadedFile

[](#load-from-laravel-uploadedfile)

```
ExcelTo::upload($request->file('excel'))->toCollection();
```

### Load a CSV

[](#load-a-csv)

```
ExcelTo::file('path/to/file.csv')->toArray();
```

---

Output Formats
--------------

[](#output-formats)

```
$instance = ExcelTo::file('file.xlsx');

$instance->toArray();       // PHP array
$instance->toCollection();  // Illuminate\Support\Collection
$instance->toJson();        // JSON string
$instance->toJson(JSON_PRETTY_PRINT); // JSON with flags
```

---

Fluent Options
--------------

[](#fluent-options)

All options can be chained in any order.

### Select a Sheet

[](#select-a-sheet)

```
// By name
ExcelTo::file('file.xlsx')->sheet('Sheet2')->toArray();

// By zero-based index
ExcelTo::file('file.xlsx')->sheet(1)->toArray();
```

With a single-sheet file the result is a flat array. With multiple sheets, each sheet is a key in the result.

### Skip Empty Rows

[](#skip-empty-rows)

```
ExcelTo::file('file.xlsx')->skipEmpty()->toArray();

// Disable explicitly
ExcelTo::file('file.xlsx')->skipEmpty(false)->toArray();
```

### Custom Header Row

[](#custom-header-row)

Useful when the first row is a title and headers start on row 2:

```
ExcelTo::file('file.xlsx')->headerRow(2)->toArray();
```

### Date Format

[](#date-format)

```
// Default: 'd/m/Y'
ExcelTo::file('file.xlsx')->dateFormat('Y-m-d')->toArray();
ExcelTo::file('file.xlsx')->dateFormat('d-m-Y H:i')->toArray();
```

### Filter Columns

[](#filter-columns)

```
// Keep only these columns
ExcelTo::file('file.xlsx')->only(['nombre', 'email'])->toArray();

// Exclude these columns
ExcelTo::file('file.xlsx')->except(['id', 'internal_code'])->toArray();
```

---

Exporting to Excel
------------------

[](#exporting-to-excel)

```
use Fersot\ExcelTo\ExcelTo;

$data = [
    ['producto' => 'Widget', 'precio' => 9.99,  'stock' => 100],
    ['producto' => 'Gadget', 'precio' => 19.99, 'stock' => 50],
];

ExcelTo::fromArray($data)->export('storage/exports/report.xlsx');

// From a Collection
ExcelTo::fromCollection($collection)->export('storage/exports/report.xlsx');
```

---

Configuration
-------------

[](#configuration)

After publishing, edit `config/excel-to.php`:

```
return [
    'date_format' => 'd/m/Y',   // Default date output format
    'skip_empty'  => false,     // Skip empty rows by default
    'header_row'  => 1,         // Default header row number
];
```

Options set via the fluent API always override config values.

---

Full Example
------------

[](#full-example)

```
use Fersot\ExcelTo\ExcelTo;

$report = ExcelTo::file(storage_path('imports/ventas_2024.xlsx'))
    ->sheet('Enero')
    ->headerRow(2)
    ->skipEmpty()
    ->only(['cliente', 'importe', 'fecha'])
    ->dateFormat('Y-m-d')
    ->toCollection();

$report->each(fn($row) => \Log::info($row));
```

---

Requirements
------------

[](#requirements)

DependencyVersionPHP`^8.1`Laravel`^9.0 | ^10.0 | ^11.0 | ^12.0`PhpSpreadsheet`^1.29 | ^2.0`---

Testing
-------

[](#testing)

```
composer install
./vendor/bin/phpunit --testdox
```

25 tests covering all features.

---

Author
------

[](#author)

**Hember Colmenares** —  · [GitHub](https://github.com/fersot)

Support Me ☕️
-------------

[](#support-me-️)

If you find this package useful, consider [buying me a coffee](https://buymeacoffee.com/fersot).

[![Buy Me a Coffee](https://camo.githubusercontent.com/48e263a7a2c3a0618ed500a63b90f03fc7338cd104f35711fb6506f783c63007/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4275792532304d6525323061253230436f666665652d4646383133463f7374796c653d666f722d7468652d6261646765266c6f676f3d6275796d6561636f66666565266c6f676f436f6c6f723d7768697465)](https://buymeacoffee.com/fersot)

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance81

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~528 days

Total

2

Last Release

101d ago

Major Versions

1.0.0 → v2.0.02026-03-26

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11588218?v=4)[Hember Colmenares](/maintainers/fersot)[@fersot](https://github.com/fersot)

---

Top Contributors

[![fersot](https://avatars.githubusercontent.com/u/11588218?v=4)](https://github.com/fersot "fersot (5 commits)")

---

Tags

jsonlaravelexportexcelxlsxcsvspreadsheetcollectionphpspreadsheet

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fersot-excel-to/health.svg)

```
[![Health](https://phpackages.com/badges/fersot-excel-to/health.svg)](https://phpackages.com/packages/fersot-excel-to)
```

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.9k157.3M897](/packages/maatwebsite-excel)[avadim/fast-excel-laravel

Lightweight and very fast XLSX Excel Spreadsheet Export/Import for Laravel

4058.8k1](/packages/avadim-fast-excel-laravel)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
