how can I change sheet direction in laravel maatwebsite excel package? I want to change from left to right.
A B C D
to:
D C B A
this is my code :
$row = $this->userRepository->getById(1);
$data = $row;
Excel::create('test', function ($excel) use($data) {
$excel->sheet('sheet', function ($sheet) use($data) {
$sheet->fromArray($data, null, 'A1', false, false);
$sheet->row(1, function($row) {
});
});
})->store('xlsx', storage_path('excel/exports'))->download('xlsx');
class TractsExport implements FromCollection,WithEvents
{
public function registerEvents(): array
{
return [
BeforeSheet::class =>function(BeforeSheet $event){
$event->getDelegate()->setRightToLeft(true);
}
];
}
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
retutn Tract::all();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With