PHPackages                             dmgpage/simplexlsx - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. dmgpage/simplexlsx

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

dmgpage/simplexlsx
==================

Parse and retrieve data from Excel XLSx files. MS Excel 2007 workbooks PHP reader.

1.0.20(2y ago)059MITPHPPHP &gt;=5.5

Since Nov 28Pushed 2y agoCompare

[ Source](https://github.com/DMGPage/simplexlsx)[ Packagist](https://packagist.org/packages/dmgpage/simplexlsx)[ Docs](https://github.com/shuchkin/simplexlsx)[ RSS](/packages/dmgpage-simplexlsx/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

SimpleXLSX class
================

[](#simplexlsx-class)

[![](https://camo.githubusercontent.com/a90215a61fae996f02f5591cf7c4b3f348638bfabe9c5f7f89c7de27d603201c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73687563686b696e2f73696d706c65786c7378)](https://github.com/shuchkin/simplexlsx/blob/master/license.md)

Parse and retrieve data from Excel XLSx files. MS Excel 2007 workbooks PHP reader. No addiditional extensions need (internal unzip + standart SimpleXML parser).

This is branch of [shuchkin/simplexlsx](https://github.com/shuchkin/simplexlsx) with some additional fixes.

Basic Usage
-----------

[](#basic-usage)

```
use Shuchkin\SimpleXLSX;

if ( $xlsx = SimpleXLSX::parse('book.xlsx') ) {
    print_r( $xlsx->rows() );
} else {
    echo SimpleXLSX::parseError();
}
```

```
Array
(
    [0] => Array
        (
            [0] => ISBN
            [1] => title
            [2] => author
            [3] => publisher
            [4] => ctry
        )

    [1] => Array
        (
            [0] => 618260307
            [1] => The Hobbit
            [2] => J. R. R. Tolkien
            [3] => Houghton Mifflin
            [4] => USA
        )

)

```

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

[](#installation)

The recommended way to install this library is [through Composer](https://getcomposer.org). [New to Composer?](https://getcomposer.org/doc/00-intro.md)

This will install the latest supported version:

```
$ composer require dmgpage/simplexlsx
```

or download PHP 5.5+ class [here](https://github.com/dmgpage/simplexlsx/blob/master/src/SimpleXLSX.php)

Basic methods
-------------

[](#basic-methods)

```
// open
SimpleXLSX::parse( $filename, $is_data = false, $debug = false ): SimpleXLSX (or false)
SimpleXLSX::parseFile( $filename, $debug = false ): SimpleXLSX (or false)
SimpleXLSX::parseData( $data, $debug = false ): SimpleXLSX (or false)
// simple
$xlsx->rows($worksheetIndex = 0, $limit = 0): array
$xlsx->readRows($worksheetIndex = 0, $limit = 0): Generator - helps read huge xlsx
$xlsx->toHTML($worksheetIndex = 0, $limit = 0): string
// extended
$xlsx->rowsEx($worksheetIndex = 0, $limit = 0): array
$xlsx->readRowsEx($worksheetIndex = 0, $limit = 0): Generator - helps read huge xlsx with styles
$xlsx->toHTMLEx($worksheetIndex = 0, $limit = 0): string
// meta
$xlsx->dimension($worksheetIndex):array [num_cols, num_rows]
$xlsx->sheetsCount():int
$xlsx->sheetNames():array
$xlsx->sheetName($worksheetIndex):string
$xlsx->sheetMeta($worksheetIndex = null):array sheets metadata (null = all sheets)
$xlsx->isHiddenSheet($worksheetIndex):bool
$xlsx->getStyles():array

```

Examples
--------

[](#examples)

### XLSX to html table

[](#xlsx-to-html-table)

```
echo SimpleXLSX::parse('book.xlsx')->toHTML();
```

or

```
if ( $xlsx = SimpleXLSX::parse('book.xlsx') ) {
	echo '';
	foreach( $xlsx->rows() as $r ) {
		echo ''.implode('', $r ).'';
	}
	echo '';
} else {
	echo SimpleXLSX::parseError();
}
```

or styled html table

```
if ( $xlsx = SimpleXLSX::parse('book_styled.xlsx') ) {
    echo $xlsx->toHTMLEx();
}
```

### XLSX read huge file, xlsx to csv

[](#xlsx-read-huge-file-xlsx-to-csv)

```
if ( $xlsx = SimpleXLSX::parse( 'xlsx/books.xlsx' ) ) {
    $f = fopen('book.csv', 'wb');
	foreach ( $xlsx->readRows() as $r ) {
		fwrite($f, implode(',',$r) . PHP_EOL);
	}
	fclose($f);
} else {
	echo SimpleXLSX::parseError();
}
```

### XLSX get sheet names and sheet indexes

[](#xlsx-get-sheet-names-and-sheet-indexes)

```
// Sheet numeration started 0

if ( $xlsx = SimpleXLSX::parse( 'xlsx/books.xlsx' ) ) {
	print_r( $xlsx->sheetNames() );
	print_r( $xlsx->sheetName( $xlsx->activeSheet ) );
}
```

```
Array
(
    [0] => Sheet1
    [1] => Sheet2
    [2] => Sheet3
)
Sheet2

```

### Using rowsEx() to extract cell info

[](#using-rowsex-to-extract-cell-info)

```
$xlsx = SimpleXLSX::parse('book.xlsx');
print_r( $xlsx->rowsEx() );
```

```
Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [type] => s
                    [name] => A1
                    [value] => ISBN
                    [href] =>
                    [f] =>
                    [format] =>
                    [s] => 0
                    [css] => color: #000000;font-family: Calibri;font-size: 17px;
                    [r] => 1
                    [hidden] =>
                    [width] => 13.7109375
                    [height] => 0
                )

            [1] => Array
                (
                    [type] =>
                    [name] => B1
                    [value] => 2016-04-12 13:41:00
                    [href] =>
                    [f] =>
                    [format] => m/d/yy h:mm
                    [s] => 0
                    [css] => color: #000000;font-family: Calibri;font-size: 17px;
                    [r] => 2
                    [hidden] => 1
                    [width] => 16.5703125
                    [height] => 0
                )

```

typecell [type](http://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_ST_CellType_topic_ID0E6NEFB.html#topic_ID0E6NEFB)namecell name (A1, B11)valuecell value (1233, 1233.34, 2022-02-21 00:00:00, String) fformulasstyle index, use `$xlsx->cellFormats[ $index ]` to get stylecssgenerated cell CSSrrow indexhiddenhidden row or columnwidthwidth in [custom units](http://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_col_topic_ID0ELFQ4.html)heightheight in points (pt, 1/72 in)### Select Sheet

[](#select-sheet)

```
$xlsx = SimpleXLSX::parse('book.xlsx');
// Sheet numeration started 0, we select second worksheet
foreach( $xlsx->rows(1) as $r ) {
// ...
}
```

### Get sheet by index

[](#get-sheet-by-index)

```
$xlsx = SimpleXLSX::parse('book.xlsx');
echo 'Sheet Name 2 = '.$xlsx->sheetName(1);
```

### XLSX::parse remote data

[](#xlsxparse-remote-data)

```
if ( $xlsx = SimpleXLSX::parse('https://www.example.com/example.xlsx' ) ) {
	$dim = $xlsx->dimension(1); // don't trust dimension extracted from xml
	$num_cols = $dim[0];
	$num_rows = $dim[1];
	echo $xlsx->sheetName(1).':'.$num_cols.'x'.$num_rows;
} else {
	echo SimpleXLSX::parseError();
}
```

### XLSX::parse memory data

[](#xlsxparse-memory-data)

```
// For instance $data is a data from database or cache
if ( $xlsx = SimpleXLSX::parseData( $data ) ) {
	print_r( $xlsx->rows() );
} else {
	echo SimpleXLSX::parseError();
}
```

### Get Cell (slow)

[](#get-cell-slow)

```
echo $xlsx->getCell(0, 'B2'); // The Hobbit
```

### DateTime helpers

[](#datetime-helpers)

```
// default SimpleXLSX datetime format is YYYY-MM-DD HH:MM:SS (ISO, MySQL)
echo $xlsx->getCell(0,'C2'); // 2016-04-12 13:41:00

// custom datetime format
$xlsx->setDateTimeFormat('d.m.Y H:i');
echo $xlsx->getCell(0,'C2'); // 12.04.2016 13:41

// unixstamp
$xlsx->setDateTimeFormat('U');
$ts = $xlsx->getCell(0,'C2'); // 1460468460
echo gmdate('Y-m-d', $ts); // 2016-04-12
echo gmdate('H:i:s', $ts); // 13:41:00

// raw excel value
$xlsx->setDateTimeFormat( NULL ); // returns as excel datetime
$xd = $xlsx->getCell(0,'C2'); // 42472.570138889
echo gmdate('m/d/Y', $xlsx->unixstamp( $xd )); // 04/12/2016
echo gmdate('H:i:s', $xlsx->unixstamp( $xd )); // 13:41:00
```

### Rows with header values as keys

[](#rows-with-header-values-as-keys)

```
if ( $xlsx = SimpleXLSX::parse('books.xlsx')) {
    // Produce array keys from the array values of 1st array element
    $header_values = $rows = [];
    foreach ( $xlsx->rows() as $k => $r ) {
        if ( $k === 0 ) {
            $header_values = $r;
            continue;
        }
        $rows[] = array_combine( $header_values, $r );
    }
    print_r( $rows );
}
```

```
Array
(
    [0] => Array
        (
            [ISBN] => 618260307
            [title] => The Hobbit
            [author] => J. R. R. Tolkien
            [publisher] => Houghton Mifflin
            [ctry] => USA
        )
    [1] => Array
        (
            [ISBN] => 908606664
            [title] => Slinky Malinki
            [author] => Lynley Dodd
            [publisher] => Mallinson Rendel
            [ctry] => NZ
        )
)

```

### Debug

[](#debug)

```
use Shuchkin\SimpleXLSX;

ini_set('error_reporting', E_ALL );
ini_set('display_errors', 1 );

if ( $xlsx = SimpleXLSX::parseFile('books.xlsx', true ) ) {
	echo $xlsx->toHTML();
} else {
	echo SimpleXLSX::parseError();
}
```

### Classic OOP style

[](#classic-oop-style)

```
use SimpleXLSX;

$xlsx = new SimpleXLSX('books.xlsx'); // try...catch
if ( $xlsx->success() ) {
    foreach( $xlsx->rows() as $r ) {
        // ...
    }
} else {
    echo 'xlsx error: '.$xlsx->error();
}
```

More examples [here](https://github.com/dmgpage/simplexlsx/tree/master/examples)

### Error Codes

[](#error-codes)

SimpleXLSX::ParseErrno(), $xlsx-&gt;errno()

codemessagecomment1File not foundWhere file? UFO?2Unknown archive formatZIP?3XML-entry parser errorbad XML4XML-entry not foundbad ZIP archive5Entry not foundFile not found in ZIP archive6Worksheet not foundNot exists
 [ ![](https://camo.githubusercontent.com/139ef36f303be8bd3f07c2b14b0fc97fceebde8adc8e6d504c49a1514b1c254b/687474703a2f2f7777772e646d67706167652e6c762f696d672f6c6f676f2d626c61636b2e706e67) ](http://www.dmgpage.lv/)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 91.1% 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

901d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e1797023ded42ac8554956b5aed7bed5092bf984263180f87faf007e0b7438ef?d=identicon)[DMGPage](/maintainers/DMGPage)

---

Top Contributors

[![shuchkin](https://avatars.githubusercontent.com/u/315872?v=4)](https://github.com/shuchkin "shuchkin (175 commits)")[![DMGPage](https://avatars.githubusercontent.com/u/3495137?v=4)](https://github.com/DMGPage "DMGPage (6 commits)")[![tim-bezhashvyly](https://avatars.githubusercontent.com/u/462687?v=4)](https://github.com/tim-bezhashvyly "tim-bezhashvyly (2 commits)")[![epif4nio](https://avatars.githubusercontent.com/u/26820396?v=4)](https://github.com/epif4nio "epif4nio (1 commits)")[![hackimov](https://avatars.githubusercontent.com/u/49386760?v=4)](https://github.com/hackimov "hackimov (1 commits)")[![matheuseduardo](https://avatars.githubusercontent.com/u/99185?v=4)](https://github.com/matheuseduardo "matheuseduardo (1 commits)")[![mtwango](https://avatars.githubusercontent.com/u/40821415?v=4)](https://github.com/mtwango "mtwango (1 commits)")[![smgallo](https://avatars.githubusercontent.com/u/2301909?v=4)](https://github.com/smgallo "smgallo (1 commits)")[![acomjean](https://avatars.githubusercontent.com/u/3139639?v=4)](https://github.com/acomjean "acomjean (1 commits)")[![wimwinterberg](https://avatars.githubusercontent.com/u/806945?v=4)](https://github.com/wimwinterberg "wimwinterberg (1 commits)")[![ascweb](https://avatars.githubusercontent.com/u/3051143?v=4)](https://github.com/ascweb "ascweb (1 commits)")[![dshumko](https://avatars.githubusercontent.com/u/8360276?v=4)](https://github.com/dshumko "dshumko (1 commits)")

---

Tags

phpparserexcelxlsxbackend

### Embed Badge

![Health badge](/badges/dmgpage-simplexlsx/health.svg)

```
[![Health](https://phpackages.com/badges/dmgpage-simplexlsx/health.svg)](https://phpackages.com/packages/dmgpage-simplexlsx)
```

###  Alternatives

[shuchkin/simplexlsx

Parse and retrieve data from Excel XLSx files. MS Excel 2007 workbooks PHP reader.

1.8k3.8M21](/packages/shuchkin-simplexlsx)[shuchkin/simplexlsxgen

Export data to Excel XLSx file. PHP XLSX generator.

1.1k2.2M16](/packages/shuchkin-simplexlsxgen)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.1k57.6M131](/packages/openspout-openspout)[shuchkin/simplexls

Parse and retrieve data from old format Excel XLS files. MS Excel 97 workbooks PHP reader.

212588.3k2](/packages/shuchkin-simplexls)[avadim/fast-excel-reader

Lightweight and very fast XLSX Excel Spreadsheet Reader in PHP

104608.4k6](/packages/avadim-fast-excel-reader)[shuchkin/simplecsv

Parse and retrieve data from CSV files. Export data to CSV.

5192.4k](/packages/shuchkin-simplecsv)

PHPackages © 2026

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