PHP code example of aklump / loft_data_grids

1. Go to this page and download the library: Download aklump/loft_data_grids library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aklump / loft_data_grids example snippets


$data_grid = new \AKlump\LoftDataGrids\ExportData();

// By default we're on page 0, row 0.
$data_grid->add('Name', 'Adam')->add('Age', 39)->next();
$data_grid->add('Name', 'Brandon')->add('Age', 37)->next();
$data_grid->add('Name', 'Charlie')->add('Age', 7)->next();

// Switch to page 1; we'll be placed on row 0.
$data_grid->setPage(1);
$data_grid->add('Color', 'Black')->add('Make', 'Honda')->next();
$data_grid->add('Color', 'White')->add('Make', 'BMW')->next();

$value = $data_grid->setPage(0)->setPointer(0)->getValue('Name') // $value === 'Adam'
$value = $data_grid->getValue('Name') // $value === 'Adam'
$value = $data_grid->setPointer(2)->getValue('Name') // $value === 'Charlie'
$value = $data_grid->setPointer(0)->get() // $value === array('Name' => 'Adam', 'Age' => 39)
$value = $data_grid->setPage(1)->setPointer(1)->getValue('Color') // $value === 'White'

$exporter = new \AKlump\LoftDataGrids\CSVExporter($data_grid);

$csv_string = $exporter->export();
// "Name","Age"
// "Adam","39"
// "Brandon","37"
// "Charlie","7"

$csv_string = $exporter->export(1);
// "Color","Make"
// "Black","Honda"
// "White","BMW"

$exporter = new \AKlump\LoftDataGrids\JSONExporter($data_grid);
$json_string = $exporter->export();

$exporter = new \AKlump\LoftDataGrids\XLSXExporter($data_grid, 'users');
$exporter->saveFile();