Laravel Maatwebsite Excel Increase Font Size Example

About Us:

We are from free coder. We are a group of web developers who are passionate about web development. You can learn from us php, laravel, node js, vue js, react js and many other topic on web developement.
we are very happy to help you.
free coder

Today what you are going to learn:

This post is focused on laravel maatwebsite excel increase font size. we will help you to give lesson of laravel excel increase font size. i explained simply step by step laravel maatwebsite setSize(). you will learn how to add font size in laravel excel maatwebsite.

We will use setSize() for increase font size in laravel maatwesite composer package. you can use this lesson with laravel 6, laravel 7 and laravel 8 version.

You can follow bellow url for checking full lesson of Import and Export Excel File with laravel. Here i will give you solution with export class:

Laravel Import Export Excel and CSV File Tutorial

Solution:

app/Exports/UsersExport.php

<?php

namespace App\Exports;

use App\Models\User;

use Maatwebsite\Excel\Concerns\FromCollection;

use Maatwebsite\Excel\Concerns\WithHeadings;

use Maatwebsite\Excel\Concerns\WithEvents;

use Maatwebsite\Excel\Events\AfterSheet;

class UsersExport implements FromCollection, WithHeadings, WithEvents

{

/**

* Write code on Method

*

* @return response()

*/

public function collection()

{

return User::select("id", "name", "email")->get();

}

/**

* Write code on Method

*

* @return response()

*/

public function headings() :array

{

return [

'ID',

'Name',

'Email',

];

}

/**

* Write code on Method

*

* @return response()

*/

public function registerEvents(): array

{

return [

AfterSheet::class => function(AfterSheet $event) {

$event->sheet->getDelegate()->getStyle('1')->getFont()->setSize(16);

},

];

}

}

Result:-

thank you very much for following up with me.

Tags

Recent Posts

Related Posts