PHP code example of xerobase / excel-reporter

1. Go to this page and download the library: Download xerobase/excel-reporter 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/ */

    

xerobase / excel-reporter example snippets


$exporter = new \Xerobase\ExcelReporter\Export();

// Your source can be an Eloquent Model
$books = \App\Models\Book::all();

// Or an associative array
$books = [
  'Title' => 'Foo',
  'Author' => 'Bar'
];

// Or an stdClass object
$books = new stdClass();
$books->title = 'Foo';
$books->author = 'Bar';

$exporter->export($books);

$exporter->filterColumns(['id', 'created_at', 'updated_at'])->export($books);

$exporter->setRightToLeft()->export($books);

$exporter->setFormat('csv')->export($books);