PHPackages                             kang-babi/spreadsheet - 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. kang-babi/spreadsheet

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

kang-babi/spreadsheet
=====================

Wrapper for PhpSpreadsheet

v1.2.0(1y ago)026↓100%MITPHPPHP ^8.1

Since Jan 31Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/kang-babi/spreadsheet)[ Packagist](https://packagist.org/packages/kang-babi/spreadsheet)[ RSS](/packages/kang-babi-spreadsheet/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (6)Versions (11)Used By (0)

Spreadsheet Wrapper Library
===========================

[](#spreadsheet-wrapper-library)

This library is built on top of [PhpSpreadsheet](https://github.com/PHPOffice/PhpSpreadsheet), serving as a wrapper to simplify the creation and manipulation of spreadsheet files in PHP. It provides a fluent interface utilizing method chaining, closures to enhance usability and readability.

Limitation
----------

[](#limitation)

> While the library is fully tested and suitable for production use, it offers limited functionality compared to the underlying PhpSpreadsheet library. For more advanced features, consider using PhpSpreadsheet directly.

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

[](#installation)

Ensure you have [Composer](https://getcomposer.org/) installed. Then, add the library to your project:

```
composer require kang-babi/spreadsheet
```

Usage
-----

[](#usage)

1. Initialize the Sheet

```
use KangBabi\Spreadsheet\Sheet;

$sheet = new Sheet();

$sheet->getSpreadsheetInstance(); # returns \PhpOffice\PhpSpreadsheet\Spreadsheet instance
$sheet->getActiveSheet(); # returns \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet instance
```

2. Configure Sheet

```
use KangBabi\Spreadsheet\Wrappers\Config;

$sheet->config(function (Config $config): void {
  ->orientation('portrait')
  ->pageFit('page') # fits to page
  ->repeatRows(1, 5) # repeats row 1 to 5
  ->paperSize('a4')
  ->columnWidth('A', 13)
});
```

3. Header

```
use KangBabi\Spreadsheet\Wrappers\Builder;
use KangBabi\Spreadsheet\Wrappers\Row;

$sheet->header(function (Builder $header): void {
  $header
    ->row(function (Row $row): void { # rows start at 1 and increments per row chain
      $row
        ->merge('A', 'H') # merges columns A to H at the current row
        ->value('A', 'THIS IS MY HEADER')
        ->style('A:H', function (Style $style) { # targets A to H at the current row
          $style
            ->fontName('Times New Roman')
            ->alignment('horizontal', 'center') # or use ->horizontal('center')
            ->alignment('vertical', 'top') # or use ->vertical('top')
            ->border('all')
            ->border('bottom', 'none')
            ->strikethrough()
            ->italic();
        });
  })
  ->jump(2) # skips 2 rows and do nothing
  ->then(1, function (Row $row): void {...}); # jumps 1 row and builds row
});
```

4. Body and Footer is wrapped with Builder instance.
5. Rich Text

```
use KangBabi\Spreadsheet\Misc\RichText;

$richText = RichText::make()
  ->text("Initial text ")
  ->bold()
  ->italic()
  ->size(11)
  ->fontName('Times New Roman')
  ->text('additional text ')
  ->size(8)
  ->fontName('Georgia')
  ->strikethrough()
  ->underline();

...
$row
  ->value('A', $richText)
...
```

6. Image (Drawing)

```
use KangBabi\Spreadsheet\Misc\Image;

$image = Image::make()
  ->source('path/to/img/')
  ->from('A1')
  ->to('B1') # stretch image to B2
  ->padX(10, false) # pads left as default, set true to pad right
  ->padY(10, false) # pads top as default, set true to pad bottom
  ->height(100);
```

7. Macro - You can define reusable macros to streamline repetitive tasks.

- Row

```
Row::macro('row', function (Row $row): void {
  $row
    ->value('A', 'Has')
    ->value('B', 'Macros');
});

$row = new Row();

# call macro
$row->call('row', $row);

# or

# call macro
Row::staticCall('row', $row);
```

- Builder

```
Builder::macro('skip', function (Builder $builder): void {
  $builder
    ->jump()
    ->row(function (Row $row) {
      ...
    });
})

$builder = new Builder();

#call macro
$builder->call('skip', $builder);

# or

# call macro
Builder::staticCall('skip', $builder);
```

8. Color &amp; Fill - Save color configurations and apply them to Color Fill

- Color - Color values follow the ARGB format and values will be prefixed with 'F'

```
use KangBabi\Misc\Color;

$colors = Color::make()
  ->set('primary', '696cff') # results to 'FF696cff'
  ->set('secondary', '8592a3')
  ->set('success', '71dd37')

# access color values
$colors->get('primary'); # returns 'FF696cff'

# or
$colors->success; # returns 'FF71dd37'

# or static
Color::color('secondary'); # returns 'FF8592a3'

# get all colors
$colors->all();
/**
 * returns [
 *  'primary' => 'FF696cff',
 *  'secondary' => 'FF8592a3',
 *  'success' => 'FF71dd37',
 * ]
 */

# or static
Color::colors();
/**
 * returns [
 *  'primary' => 'FF696cff',
 *  'secondary' => 'FF8592a3',
 *  'success' => 'FF71dd37',
 * ]
 */

# Setting default color
Color::default('primary');

# trigger default
$colors->doesNotExist; # returns 'FF696cff'
$colors->get('doesNotExist'); # returns 'FF696cff'

# or static
Color::color('doesNotExist'); # returns 'FF696cff'
```

- Fill - fill cell with predefined colors

```
# from step 1

...
  $style
    ->horizontal('center')
    ->fill(Color::color('primary')) # default solid
    ->fill($colors->info, 'none') # fills none
...
```

9. Save the Sheet

```
$wrapText = true;

$sheet->save('my-sheet', $wrapText); # saves sheet as my-sheet.xlsx, wrap text is enabled by default
```

###  Health Score

32

—

LowBetter than 74% of packages

Maintenance51

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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

Every ~5 days

Total

10

Last Release

370d ago

PHP version history (2 changes)v1.0.0PHP ^8.3

v1.0.5PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/b0387b69f67b51e12f244c06d31bd1d65e08be8879170e7ef168881f5f037d68?d=identicon)[kang-babi](/maintainers/kang-babi)

---

Top Contributors

[![kang-babi](https://avatars.githubusercontent.com/u/81248294?v=4)](https://github.com/kang-babi "kang-babi (69 commits)")

###  Code Quality

TestsPest

Static AnalysisRector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/kang-babi-spreadsheet/health.svg)

```
[![Health](https://phpackages.com/badges/kang-babi-spreadsheet/health.svg)](https://phpackages.com/packages/kang-babi-spreadsheet)
```

###  Alternatives

[civicrm/civicrm-core

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

718267.0k11](/packages/civicrm-civicrm-core)[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)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52658.0k8](/packages/solspace-craft-freeform)[pimcore/data-importer

Adds a comprehensive import functionality to Pimcore Datahub

44732.1k2](/packages/pimcore-data-importer)[terminal42/contao-leads

Leads extension for Contao Open Source CMS; Store and manage form data with ease!

41164.9k8](/packages/terminal42-contao-leads)

PHPackages © 2026

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