lyquidity/php-pivottables-4-excel-lite

Adds limited Excel pivot table functionality to PHPOffice/PHPSpreadsheet

dev-master 2021-11-27 00:32 UTC

This package is auto-updated.

Last update: 2024-10-27 07:24:37 UTC


README

PHPOffice/PhpSpreadsheet is a great project to read and write Excel workbook but it does not support some Excel features such as Tables and Pivot Tables. This project extends PhpSpreadsheet by adding support for pivot tables but only in a limited way.

What is supported?

This project ensures that existing pivot tables are retained and allows pivot tables to be created to report on data in worksheets.
The rows and columns can be defined based on columns in the worksheet and they can be filtered and sorted. Only Xlsx/Xlsm files are supported.

What is not supported?

The pivot table features not supported include:

  • External data sources
  • Styling
  • Hierarchies
  • Formulas
  • File types other than Xlsx

However, there is no reason why support for these features cannot be added and the project shows how additional features can be implemented.

Installing

Use composer with the command:

composer require lyquidity/php-pivottables-4-excel-lite:dev-master --prefer-dist

Getting started

The ./examples/example.php file includes illustrations of using the classes.

Assuming you have installed the library using composer then this PHP application will run the test:

<?php
require_once __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/vendor/lyquidity/php-pivottables-4-excel-lite/examples/example.php';

The examples use the following simple data set:

Overridden Classes

To implement support for pivot tables it has been necessary to override 5 classes:

New classes

In addition eight new classes are added: