Skip to content

obixav/maatwebsite-laravel-excel-export-dropdown-columns

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Maatwebsite Laravel Excel Export Dropdown Columns

Maatwebsite Laravel Excel is a simple, but elegant Laravel wrapper around PhpSpreadsheet exports and imports.

You can have dropdown columns in Laravel Excel Export

Open the example export User Export

All select options are defined in the constructor

    public function __construct()
    {
        $status=['active','pending','disabled'];
        $departments=['Account','Admin','Ict','Sales'];
        $selects=[  //selects should have column_name and options
            ['columns_name'=>'D','options'=>$departments],
            ['columns_name'=>'E','options'=>$status],
        ];
        $this->selects=$selects;
        $this->row_count=50;//number of rows that will have the dropdown
        $this->column_count=5;//number of columns to be auto sized
    }

Your column options could be from the database

$roles=Role::pluck('name')->toArray();

The registerEvents method will loop through the data in the $selects array and populate the excel export and add validation

Credits

This is based on a response from here

About

Have multiple dropdown columns in Laravel Excel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%