2017 © Pedro Peláez
 

library stats-table

Helper to handle stats table with multiple formatter

image

igraal/stats-table

Helper to handle stats table with multiple formatter

  • Thursday, March 29, 2018
  • by paxal
  • Repository
  • 11 Watchers
  • 8 Stars
  • 16,030 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 5 % Grown

The README.md

stats-table

PHP Library to handle statistics tables and CSV, JSON and Excel exports. Build Status, (*1)

Summary

This library helps you create statistical tables given some data. You provide data, headers and what you want for the footer line, and then you can dump your table into a JSON, CSV or Excel file., (*2)

This is very useful to manipulate a lot of tables you want to see in an HTML FrontOffice and when you want to add the ability to get this data in CSV or Excel File as well., (*3)

Installation

Using composer

Using composer, just add the following require to your composer.json :, (*4)

"require": {
    ... ,
    "igraal/stats-table": "dev-master"
}

Usage

Using the class StatsTable

The class StatsTable is the class that will hold your data. It takes one mandotary arguments, and 4 options arguments. The simpler way to create a new table is to pass the data itself and its headers (even if headers are optional)., (*5)

use IgraalOSL\StatsTable\StatsTable;

$data = [
    ['date' => '2014-01-01', 'hits' => 32500],
    ['date' => '2014-01-02', 'hits' => 48650],
];
$headers = ['date' => 'Date', 'hits' => 'Number of hits'];
$statsTable = new StatsTable($data, $headers);

Dumping a table

Three formats are currently supported : Excel, CSV and JSON. Thus, you can use the same table with your ajax calls or to be downloaded., (*6)

First, create your dumper, then dump your data., (*7)

use IgraalOSL\StatsTable\Dumper\Excel\ExcelDumper;

$excelDumper = new ExcelDumper();
$excelContents = $excelDumper->dump($statsTable);

header('Content-type: application/vnd.ms-excel');
echo $excelContents

Using stats table builder

To help you construct a table, you can use the StatsTableBuilder class. It helps you combine data from multiple tables, and can create automatic calculated columns. It also helps you build aggregations (aka the footer line), with multiple possibilities : ratio, sum, average or static content., (*8)

use IgraalOSL\StatsTable\StatsTableBuilder;

$data = [
    '2014-01-01' => ['hits' => 32500],
    '2014-01-02' => ['hits' => 48650],
];

$statsTableBuilder = new StatsTableBuilder(
    $data,
    ['hits' => 'Number of hits']
);
$statsTableBuilder->addIndexesAsColumn('date', 'Date');

$statsTable = $statsTableBuilder->build();

The Versions

29/03 2018

dev-master

9999999-dev https://github.com/igraal/stats-table

Helper to handle stats table with multiple formatter

  Sources   Download

MIT

The Requires

 

The Development Requires

statistics csv php json excel xls stats

29/03 2018

v1.0.0

1.0.0.0 https://github.com/igraal/stats-table

Helper to handle stats table with multiple formatter

  Sources   Download

MIT

The Requires

 

The Development Requires

statistics csv php json excel xls stats

29/03 2018

dev-reformat

dev-reformat https://github.com/igraal/stats-table

Helper to handle stats table with multiple formatter

  Sources   Download

MIT

The Requires

 

The Development Requires

statistics csv php json excel xls stats

29/03 2018

dev-phpspreadsheet

dev-phpspreadsheet https://github.com/igraal/stats-table

Helper to handle stats table with multiple formatter

  Sources   Download

MIT

The Requires

 

The Development Requires

statistics csv php json excel xls stats

14/04 2015

v0.1.0

0.1.0.0 https://github.com/igraal/stats-table

Helper to handle stats table with multiple formatter

  Sources   Download

MIT

The Requires

 

The Development Requires

statistics csv php json excel xls stats