PHPackages                             allegedwizard/php-spreadsheets - 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. allegedwizard/php-spreadsheets

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

allegedwizard/php-spreadsheets
==============================

A spreadsheet parser wrapper utility, preferring OpenSpout with fallback to PhpSpreadsheet.

v1.0.0(3d ago)01↓100%MITPHPPHP ^8.0

Since Mar 21Pushed 3d agoCompare

[ Source](https://github.com/allegedwizard/php-spreadsheets)[ Packagist](https://packagist.org/packages/allegedwizard/php-spreadsheets)[ RSS](/packages/allegedwizard-php-spreadsheets/feed)WikiDiscussions main Synced today

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

PHP Spreadsheets
================

[](#php-spreadsheets)

This package is a wrapper utility interface for reading/writing spreadsheets, preferring OpenSpout with fallback to PhpSpreadsheet

Supports reading and writing XLSX, XLS, CSV, TXT, and ODS files.

Built on top of [OpenSpout](https://github.com/openspout/openspout) and [PhpSpreadsheet](https://github.com/PHPOffice/PhpSpreadsheet).

Created by [Alleged Wizard](https://allegedwizard.com).

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

[](#installation)

```
composer require allegedwizard/php-spreadsheets:^1.0
```

Reading
-------

[](#reading)

```
use AllegedWizard\PhpSpreadsheets\Spreadsheets;

$spreadsheet = new Spreadsheets('/path/to/file.xlsx');

// Get all rows as associative arrays keyed by header columns
$rows = $spreadsheet->toArray();

// Get column headers
$columns = $spreadsheet->getColumns();

// Get row counts per sheet
$counts = $spreadsheet->getRowCount();

// Check for multiple sheets
if ($spreadsheet->hasMultipleSheets()) {
    $sheetName = $spreadsheet->getSheetName($sheetKey);
}
```

### Limiting Columns

[](#limiting-columns)

```
$spreadsheet = new Spreadsheets('/path/to/file.xlsx');

// Return only specific columns
$spreadsheet->setLimitColumns(['Name', 'Email']);

// Wildcard support: return all columns starting with "Address"
$spreadsheet->setLimitColumns(['Address**']);

$rows = $spreadsheet->toArray();
```

### Overriding File Extension

[](#overriding-file-extension)

By default, the reader and writer infer the file type from the file extension. Use the third parameter to override this when the extension doesn't match the actual format.

```
// Treat a .txt file as CSV
$spreadsheet = new Spreadsheets('/path/to/file.txt', 'read', 'csv');
```

Writing
-------

[](#writing)

```
use AllegedWizard\PhpSpreadsheets\Spreadsheets;

$records = [
    ['Name' => 'Alice', 'Email' => 'alice@example.com'],
    ['Name' => 'Bob', 'Email' => 'bob@example.com'],
];

$spreadsheet = new Spreadsheets('/path/to/output.xlsx', 'write');
$spreadsheet->write($records);
```

### XLSX Header Formatting

[](#xlsx-header-formatting)

By default, XLSX output will freeze and bold the first row (header). To disable either behavior:

```
$spreadsheet = new Spreadsheets('/path/to/output.xlsx', 'write');
$spreadsheet->setFreezeHeader(false);
$spreadsheet->setBoldHeader(false);
$spreadsheet->write($records);
```

### Column Model

[](#column-model)

Define per-column width and type for styled XLSX output:

```
$model = [
    'Name'   => ['width' => 30, 'type' => 'string'],
    'Amount' => ['width' => 15, 'type' => 'currency'],
    'Date'   => ['width' => 20, 'type' => 'date'],
];

$spreadsheet->write($records, $model);
```

Supported types: `string`, `number`, `currency`, `date`, `boolean`.

### Multiple Sheets

[](#multiple-sheets)

```
// Rename the single sheet
$spreadsheet->write($records, [], 'My Sheet');

// Write multiple sheets
$multiSheetRecords = [
    'Users'  => $userRecords,
    'Orders' => $orderRecords,
];

$spreadsheet->write($multiSheetRecords, [], true);
```

### Optimized Write Mode

[](#optimized-write-mode)

When records are structured as separate `columns` and `rows` arrays:

```
$records = [
    'columns' => ['Name', 'Email'],
    'rows' => [
        ['Alice', 'alice@example.com'],
        ['Bob', 'bob@example.com'],
    ],
];

$spreadsheet->write($records, [], false, true);
```

CSV Utility
-----------

[](#csv-utility)

Convert an associative array to a CSV string:

```
$csv = Spreadsheets::arrayToCsv($records);
```

Testing
-------

[](#testing)

```
composer install
composer test
```

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance99

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

3d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/120d13ff55f4b8a218b1651de33eec9c2167b06968c4328e2ef9475174db3d76?d=identicon)[allegedwizard](/maintainers/allegedwizard)

---

Top Contributors

[![zawntech](https://avatars.githubusercontent.com/u/12899159?v=4)](https://github.com/zawntech "zawntech (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/allegedwizard-php-spreadsheets/health.svg)

```
[![Health](https://phpackages.com/badges/allegedwizard-php-spreadsheets/health.svg)](https://phpackages.com/packages/allegedwizard-php-spreadsheets)
```

###  Alternatives

[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

718267.0k11](/packages/civicrm-civicrm-core)[craftcms/feed-me

Import content from XML, RSS, CSV or JSON feeds into entries, categories, Craft Commerce products, and more.

292919.2k18](/packages/craftcms-feed-me)[in2code/powermail

Powermail is a well-known, editor-friendly, powerful and easy to use mailform extension for TYPO3 with a lots of features

982.4M36](/packages/in2code-powermail)[yectep/phpspreadsheet-bundle

A Symfony bundle to integrate with PHPOffice's PhpSpreadsheet library

592.3M3](/packages/yectep-phpspreadsheet-bundle)[pimcore/data-importer

Adds a comprehensive import functionality to Pimcore Datahub

44732.1k2](/packages/pimcore-data-importer)[instride/data-definitions

Data Definitions allows you to define your DataObject Imports and Exports using a nice GUI and re-run the definitions as often you like.

8116.2k](/packages/instride-data-definitions)

PHPackages © 2026

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