PHPackages                             jhesyong/simple-excel-parser - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. jhesyong/simple-excel-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

jhesyong/simple-excel-parser
============================

A simple excel parser based on phpoffice/phpexcel

v1.0(11y ago)019LGPLPHPPHP &gt;=5.4.0

Since Mar 14Pushed 10y ago1 watchersCompare

[ Source](https://github.com/jhesyong/simple-excel-parser)[ Packagist](https://packagist.org/packages/jhesyong/simple-excel-parser)[ RSS](/packages/jhesyong-simple-excel-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Simple Excel Parser
===================

[](#simple-excel-parser)

A simple excel parser that parses each row to an associative array.

When to use this?
-----------------

[](#when-to-use-this)

- Your excel file has the header at the first row, and data at the rest rows.
- You want to map the header titles to database keys.
- You want to map the data values to database enums.

Example
-------

[](#example)

You want to parse an excel file with the following format.

NameAgeGenderPhone 1Phone 2Bill18Male222-222-2222777-777-7777Peter25Male222-333-4444555-666-7777Monica31Female666-666-6666555-555-5555And you want to map the header titles to database table fields, and map genders to `'m'` or `'f'`.

```
$parser = new Jhesyong\Excel\Parser;

// Map 'Name' to 'name', 'Age' to 'age', and 'Gender' to 'gender'.
$parser->addHeader('Name', 'name');
$parser->addHeader('Age', 'age');

// Map the values: 'm' is for 'Male', and 'f' is for 'Female'
$parser->addHeader('Gender', 'gender')->withOptions(['m' => 'Male', 'f' => 'Female']);

// You can use a regular expression and pass a callback to map multiple header titles.
// In this case, 'Phone 1' will be mapped to 'phone_1'
$parser->addHeader('/^Phone \d+$/', function($title)
{
    return str_replace(' ', '_', strtolower($title));
});

// Load the file and start to parse. Pass a callback function
// and it will be called for each row.
$parser->loadFile('filename.xlsx')->parse(function($data)
{
    // Data will be an associative array.
    var_dump($data);
});

```

FAQ
---

[](#faq)

### I have multiple titles of the same text, but I want to map them to different database table fields.

[](#i-have-multiple-titles-of-the-same-text-but-i-want-to-map-them-to-different-database-table-fields)

You can add headers with the same title but different field names in the desired order.

```
// The first 'Phone' will be mapped to 'phone_1',
// and the second 'Phone' will be mapped to 'phone_2'
$parser->addHeader('Phone', 'phone_1');
$parser->addHeader('Phone', 'phone_2');

```

### I just want to use the title as the field name

[](#i-just-want-to-use-the-title-as-the-field-name)

You can omit the second argument.

```
// 'Phone' will be mapped to 'Phone'
$parser->addHeader('Phone');

```

### I want to pre-define the header mapping and the options.

[](#i-want-to-pre-define-the-header-mapping-and-the-options)

You can extend the `Parser` and write your rules in the constructor.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

4073d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/254ed8d0824071feca5804dba9b68935974e155ddbc8289959e7828c66b7567b?d=identicon)[jhesyong](/maintainers/jhesyong)

---

Top Contributors

[![jhesyong](https://avatars.githubusercontent.com/u/8470147?v=4)](https://github.com/jhesyong "jhesyong (9 commits)")

### Embed Badge

![Health badge](/badges/jhesyong-simple-excel-parser/health.svg)

```
[![Health](https://phpackages.com/badges/jhesyong-simple-excel-parser/health.svg)](https://phpackages.com/packages/jhesyong-simple-excel-parser)
```

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M282](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M226](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M63](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M343](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

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