PHPackages                             infostreams/excel-merge - 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. infostreams/excel-merge

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

infostreams/excel-merge
=======================

A PHP library to merge two or more Excel files into one

0.8.6(5y ago)3875.3k↓47.3%171MITPHP

Since Feb 15Pushed 3y ago3 watchersCompare

[ Source](https://github.com/infostreams/excel-merge)[ Packagist](https://packagist.org/packages/infostreams/excel-merge)[ RSS](/packages/infostreams-excel-merge/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)DependenciesVersions (8)Used By (1)

Excel Merge
===========

[](#excel-merge)

Merges two or more Excel files into one file, while keeping formatting, formulas, VBA code and conditional styling intact. This software works with Excel 2007 (.xlsx and .xlsm) files and can only generate Excel 2007 files as output. The older .xls format is unfortunately not supported, but you can work around that if necessary.

This is a software library that is designed to be used as part of a larger piece of software. It cannot be used as standalone software by itself.

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

[](#installation)

**With composer**

```
php composer.phar require infostreams/excel-merge

```

Use
---

[](#use)

The most basic use of this software looks something like this

```

```

Raison d'être and use case
--------------------------

[](#raison-dêtre-and-use-case)

This library exists for one reason only: to work around the humongous memory requirements of the otherwise excellent [PHPExcel](https://github.com/PHPOffice/PHPExcel) library. I had to export the contents of a database as an Excel file with about 10 worksheets, some of them relatively large, and PHPExcel very quickly ran out of memory after producing about 2 or 3 of the required worksheets, even after increasing the PHP memory limit to 256 and then 512 Mb. I was not doing anything spectacular and am certainly [not the only one](http://stackoverflow.com/questions/4817651/phpexcel-runs-out-of-256-512-and-also-1024mb-of-ram)to have run into this issue.

At this point I could have chosen a different Excel library to generate the export, and [I did](https://github.com/MAXakaWIZARD/xls-writer), but these would not allow me to use VBA code in my exported file, and would not recognize some of the Excel formulas I needed. PHPExcel would allow me to do these things, but ran out of memory because it insists on keeping a complete mental model of all the sheets in memory before it could produce an output file. That makes sense for PHPExcel but doesn't work for my use case.

Therefore, I decided to circumvent PHPExcel's memory limitations by using it to generate and then write all sheets as **individual Excel files**, and then write some code to merge these Excel files into one.

How it works
------------

[](#how-it-works)

Instead of trying to keep a mental model of the whole Excel file in memory, this library simply operates directly on the XML files that are inside Excel2007 files. The library doesn't really understand these XML files, it just knows which files it needs to copy where and how to modify the XML in order to add one sheet of one Excel file to the other.

This means that the most memory it will ever use is directly related to how large your largest worksheet is.

Results
-------

[](#results)

I had to generate an Excel file with 11 relatively sizable worksheets (two or three sheets with about 2000 rows). PHPExcel took over 30 minutes and over 512 Mb of memory to generate this, after which I aborted the process. With this library, I can generate the same export in 28.2 seconds with a peak memory use of 67 Mb.

Support for 'native' Excel files
--------------------------------

[](#support-for-native-excel-files)

I've tried merging files produced by Excel itself, but somehow it fails. I worked around it by loading the file with PHPExcel and writing it as a new Excel2007 file, and then merging that instead. If you figure out why it fails: pull requests welcome.

Support for .xls files and Libre/OpenOffice Calc and Gnumeric
-------------------------------------------------------------

[](#support-for-xls-files-and-libreopenoffice-calc-and-gnumeric)

You can merge .xls files, or any of the import formats supported by PHPExcel, by reading the file with PHPExcel and writing it as a temporary Excel2007 file. You then merge the temporary Excel2007 file instead of the original file

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

[](#requirements)

This library uses DOMDocument and DOMXPath extensively. These are installed and available in PHP5 by default. If they aren't, check [here](http://php.net/manual/en/dom.setup.php).

Minimum PHP version is most likely v5.3.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.2% 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 ~324 days

Recently: every ~465 days

Total

7

Last Release

1843d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1132744?v=4)[Edward Akerboom](/maintainers/infostreams)[@infostreams](https://github.com/infostreams)

---

Top Contributors

[![infostreams](https://avatars.githubusercontent.com/u/1132744?v=4)](https://github.com/infostreams "infostreams (15 commits)")[![carolineclep](https://avatars.githubusercontent.com/u/23006924?v=4)](https://github.com/carolineclep "carolineclep (4 commits)")[![mdanko2000](https://avatars.githubusercontent.com/u/83007116?v=4)](https://github.com/mdanko2000 "mdanko2000 (3 commits)")

---

Tags

combineexcelmergephpexcelworksheetxlsxexcelxlsxlsxPHPExcelmergecombinexlsm

### Embed Badge

![Health badge](/badges/infostreams-excel-merge/health.svg)

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

###  Alternatives

[phpoffice/phpspreadsheet

PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine

14.3k318.2M1.5k](/packages/phpoffice-phpspreadsheet)[rap2hpoutre/fast-excel

Fast Excel import/export for Laravel

2.3k27.0M52](/packages/rap2hpoutre-fast-excel)[mk-j/php_xlsxwriter

PHP Library to write XLSX files

1.9k8.7M31](/packages/mk-j-php-xlsxwriter)[avadim/fast-excel-writer

Lightweight and very fast XLSX Excel Spreadsheet Writer in PHP

3051.4M11](/packages/avadim-fast-excel-writer)[avadim/fast-excel-reader

Lightweight and very fast XLSX Excel Spreadsheet and CSV Reader in PHP

107737.8k11](/packages/avadim-fast-excel-reader)[nuovo/spreadsheet-reader

Spreadsheet reader library for Excel, OpenOffice and structured text files

671891.8k8](/packages/nuovo-spreadsheet-reader)

PHPackages © 2026

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