{"id":19614983,"url":"https://github.com/infostreams/excel-merge","last_synced_at":"2025-10-05T12:34:00.142Z","repository":{"id":45748976,"uuid":"51750513","full_name":"infostreams/excel-merge","owner":"infostreams","description":"A PHP library to merge two or more Excel files into one","archived":false,"fork":false,"pushed_at":"2023-06-01T12:47:20.000Z","size":31,"stargazers_count":37,"open_issues_count":0,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-28T07:18:37.823Z","etag":null,"topics":["combine","excel","merge","phpexcel","worksheet","xlsx"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/infostreams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-15T11:15:53.000Z","updated_at":"2025-05-28T09:19:12.000Z","dependencies_parsed_at":"2024-06-21T03:54:31.735Z","dependency_job_id":"a497fb4d-3c5d-49ff-8f24-cf94bcc71496","html_url":"https://github.com/infostreams/excel-merge","commit_stats":{"total_commits":16,"total_committers":3,"mean_commits":5.333333333333333,"dds":0.3125,"last_synced_commit":"f688a2d5c25df5f6e36b17e762f977836a992616"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/infostreams/excel-merge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infostreams%2Fexcel-merge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infostreams%2Fexcel-merge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infostreams%2Fexcel-merge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infostreams%2Fexcel-merge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/infostreams","download_url":"https://codeload.github.com/infostreams/excel-merge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infostreams%2Fexcel-merge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278457433,"owners_count":25989952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["combine","excel","merge","phpexcel","worksheet","xlsx"],"created_at":"2024-11-11T10:54:42.042Z","updated_at":"2025-10-05T12:34:00.113Z","avatar_url":"https://github.com/infostreams.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Excel Merge\n===========\n\nMerges two or more Excel files into one file, while keeping formatting, formulas, VBA code and \nconditional styling intact. This software works with Excel 2007 (.xlsx and .xlsm) files and can \nonly generate Excel 2007 files as output. The older .xls format is unfortunately not supported, \nbut you can work around that if necessary. \n\nThis is a software library that is designed to be used as part of a larger piece of software. It \ncannot be used as standalone software by itself.\n\nInstallation\n------------\n\n**With composer**\n\n    php composer.phar require infostreams/excel-merge\n\nUse\n---\n\nThe most basic use of this software looks something like this \n\n    \u003c?php\n      require(\"vendor/autoload.php\");\n    \n      $files = array(\"sheet_with_vba_code.xlsm\", \"generated_file.xlsx\", \"tmp/third_file.xlsx\");\n      \n      $merged = new ExcelMerge\\ExcelMerge($files);            \n      $merged-\u003edownload(\"my-filename.xlsm\");\n      \n      // or\n      \n      $filename = $merged-\u003esave(\"my-directory/my-filename.xlsm\");\n    ?\u003e\n\n\nRaison d'être and use case\n--------------------------\nThis library exists for one reason only: to work around the humongous memory requirements of the\notherwise excellent [PHPExcel](https://github.com/PHPOffice/PHPExcel) library. I had to export\nthe contents of a database as an Excel file with about 10 worksheets, some of them relatively \nlarge, and PHPExcel very quickly ran out of memory after producing about 2 or 3 of the required \nworksheets, even after increasing the PHP memory limit to 256 and then 512 Mb. I was not doing \nanything spectacular and am certainly \n[not the only one](http://stackoverflow.com/questions/4817651/phpexcel-runs-out-of-256-512-and-also-1024mb-of-ram) \nto have run into this issue.\n\nAt this point I could have chosen a different Excel library to generate the export, and \n[I did](https://github.com/MAXakaWIZARD/xls-writer), but these would not allow me to use VBA code\nin my exported file, and would not recognize some of the Excel formulas I needed. PHPExcel would\nallow me to do these things, but ran out of memory because it insists on keeping a complete mental\nmodel of all the sheets in memory before it could produce an output file. That makes sense for \nPHPExcel but doesn't work for my use case.\n\nTherefore, I decided to circumvent PHPExcel's memory limitations by using it to generate and then \nwrite all sheets as **individual Excel files**, and then write some code to merge these Excel\nfiles into one.\n\nHow it works\n------------\nInstead of trying to keep a mental model of the whole Excel file in memory, this library simply \noperates directly on the XML files that are inside Excel2007 files. The library doesn't \nreally understand these XML files, it just knows which files it needs to copy where and how to\nmodify the XML in order to add one sheet of one Excel file to the other. \n\nThis means that the most memory it will ever use is directly related to how large your largest\nworksheet is. \n\nResults\n-------\nI had to generate an Excel file with 11 relatively sizable worksheets (two or three sheets with \nabout 2000 rows). PHPExcel took over 30 minutes and over 512 Mb of memory to generate this, after \nwhich I aborted the process. With this library, I can generate the same export in 28.2 seconds with \na peak memory use of 67 Mb.\n\nSupport for 'native' Excel files\n--------------------------------\nI've tried merging files produced by Excel itself, but somehow it fails. I worked around it by\nloading the file with PHPExcel and writing it as a new Excel2007 file, and then merging that \ninstead. If you figure out why it fails: pull requests welcome.\n\nSupport for .xls files and Libre/OpenOffice Calc and Gnumeric\n-------------------------------------------------------------\nYou can merge .xls files, or any of the import formats supported by PHPExcel, by reading the \nfile with PHPExcel and writing it as a temporary Excel2007 file. You then merge the temporary \nExcel2007 file instead of the original file\n\nRequirements\n------------\nThis library uses DOMDocument and DOMXPath extensively. These are installed and available in PHP5 by \ndefault. If they aren't, check [here](http://php.net/manual/en/dom.setup.php).\n\nMinimum PHP version is most likely v5.3.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfostreams%2Fexcel-merge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfostreams%2Fexcel-merge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfostreams%2Fexcel-merge/lists"}