PHP code example of taitai42 / laravel-excel

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

    

taitai42 / laravel-excel example snippets


'providers' => [
	Cyberduck\LaravelExcel\ExcelLegacyServiceProvider::class,
],

'providers' => [
	Cyberduck\LaravelExcel\ExcelServiceProvider::class,
],

namespace App\Serialisers;

use Illuminate\Database\Eloquent\Model;
use Cyberduck\LaravelExcel\Contract\SerialiserInterface;

class ExampleSerialiser implements SerialiserInterface
{
    public function getData($data)
    {
        $row = [];

        $row[] = $data->field1;
        $row[] = $data->relationship->field2;

        return $row;
    }

    public function getHeaderRow()
    {
        return [
            'Field 1',
            'Field 2 (from a relationship)'
        ];
    }
}