PHP code example of kahil-raghed / laravel-excel-extended
1. Go to this page and download the library: Download kahil-raghed/laravel-excel-extended 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/ */
kahil-raghed / laravel-excel-extended example snippets
namespace App\Exports;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use LaravelExcelExtended\Concerns\WithMaxidth;
class ProductsExport implements ShouldAutoSize, WithMaxWidth {
public function maxWidth(){
return 50;
}
}
namespace App\Exports;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use LaravelExcelExtended\Concerns\WithMaxidth;
class ProductsExport implements ShouldAutoSize, WithMaxWidth {
public function maxWidth(){
return [
'A' => 50,
'H' => 100
];
}
}
namespace App\Exports;
use LaravelExcelExtended\Concerns\WithDropdowns;
class ProductsExport implements WithDropdowns {
public function dropdowns(){
return [
'B2:B100' => [ // product size
'values' => [
'XS',
'S',
'M',
'L'
]
],
];
}
}
namespace App\Exports;
use Models\Category;
use LaravelExcelExtended\Concerns\WithDropdowns;
use LaravelExcelExtended\Helpers\Excel;
class ProductsExport implements WithDropdowns {
public function dropdowns(){
$categories = Category::all(['id', 'name']);
return [
'B2:B100' => [
'values' => $category->map(fn ($c) => $c->name),
'strategy' => Excel::LIST_STRATEGY_HIDDEN_COLUMN
],
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.