aklump / loft_data_grids
PHP Classes to allow data placement in a grid structure and exporting in various data formats.
Installs: 19 306
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 4
Forks: 4
Open Issues: 0
Language:HTML
Requires
- php: >=7.1
- phpoffice/phpspreadsheet: ^1.10
- symfony/yaml: ^3.4 || ^4 || ^5
Requires (Dev)
- phpunit/phpunit: ^7
- dev-master
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.31
- 0.4.30
- 0.4.29
- 0.4.28
- 0.4.27
- 0.4.26
- 0.4.25
- 0.4.23
- 0.4.22
- 0.4.21
- 0.4.20
- 0.4.19
- 0.4.18
- 0.4.17
- 0.4.16
- 0.4.15
- 0.4.14
- 0.4.13
- 0.4.12
- 0.4.11
- 0.4.10
- 0.4.9
- 0.4.8
- 0.4.7
- 0.4.6
- 0.4.5
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4
- 0.3.4
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3
- 0.2.2
- 0.2.1
- 0.2
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1
This package is auto-updated.
Last update: 2024-03-19 21:46:10 UTC
README
There will be no new features added to this project. Use for new projects is not advised.
This package is a PHP object-oriented solution for modelling data in two (rows + columns) or three dimensions (rows + columns + pages). It can be thought of like a spreadsheet.
It allows a single data class ExportData
to be used to organize your data in a grid, with various output styles Exporter
so you can easily get a .csv
file or a .xlsx
file, among many others.
See the code for more documentation.
Installation
- Please install necessary dependencies using Composer.
- Navigate to the root of this package and type:
composer install
Documentation
- Refer to the Doxygene documentation included in this package.
Automated Tests
PhpUnit
- Run the PhpUnit tests using phpunit.xml in the directory tests/phpunit/
Legacy: Simpletest
-
Ensure you have downloaded a copy of simpletest as
tests/simpletest/simpletest/
directory. -
Run
php all_tests.php
from the CLI using a supported PHP version. -
You should see:
all_tests.php OK Test cases run: 1/1, Passes: 32, Failures: 0, Exceptions: 0
Example Usage
Building a data object
In this example we'll build a 2 paged model, the first page contains two columns (names and ages) of three people. The second page will contain two rows of vehicle information (color and make).
$obj = new ExportData();
// By default we're on page 0, row 0.
$obj->add('Name', 'Aaron')->add('Age', 39)->next();
$obj->add('Name', 'Hillary')->add('Age', 37)->next();
$obj->add('Name', 'Maia')->add('Age', 7)->next();
// Switch to page 1; we'll be placed on row 0 when the new page is created.
$obj->setPage(1);
$obj->add('Color', 'Black')->add('Make', 'Subaru')->next();
$obj->add('Color', 'White')->add('Make', 'Hyundai')->next();
Accessing data from the object
$obj->setPage(0)->setPointer(0)->getValue('Name') === 'Aaron'
$obj->getValue('Name') === 'Aaron'
$obj->setPointer(2)->getValue('Name') === 'Maia'
$obj->setPointer(0)->get() === array('Name' => 'Aaron', 'Age' => 39)
$obj->setPage(1)->setPointer(1)->getValue('Color') === 'White'
Exporting data to other formats
And now to get that as a CSV file we do...
$exporter = new CSVExporter($obj);
$csv_string = $exporter->export();
Or to get it as JSON...
$exporter = new JSONExporter($obj);
$json_string = $exporter->export();
Or any of the other exporter classes.
Saving to File
use AKlump\LoftDataGrids\XLSXExporter;
$exporter = new XLSXExporter($obj, 'users');
$exporter->saveFile();
Contact
- In the Loft Studios
- Aaron Klump - Developer
- PO Box 29294 Bellingham, WA 98228-1294
- aim: theloft101
- skype: intheloftstudios
- d.o: aklump
- http://www.InTheLoftStudios.com