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(1mo ago)01↓100%MITPHPPHP ^8.0

Since Mar 21Pushed 1mo 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 1mo ago

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

37

—

LowBetter than 82% of packages

Maintenance97

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

48d 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

[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

22.8k69.3k](/packages/grumpydictator-firefly-iii)[civicrm/civicrm-core

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

728272.9k17](/packages/civicrm-civicrm-core)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[in2code/powermail

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

982.5M38](/packages/in2code-powermail)[laravel-enso/tables

Data Table library with server-side processing and a VueJS component

63153.4k47](/packages/laravel-enso-tables)

PHPackages © 2026

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