how to set the columns in an excel using Maatwebsite using laravel 5.4

Hi i have this download csv. Now my problem is i want to get the certain columns for my excel file not all fields from the database to be pulled to csv. Now my download csv works good and could download the data. Now i want that only certain columns to be displayed into my csv file. the getCell code wont work. This is my code below

//download csv all pending
public function downloadExcelAllPending($type){
$data = BookingHistory::orderBy('checkin_date', 'desc')->get()->toArray();

return Excel::create('booking_history', function($excel) use ($data) {

$excel->sheet('mySheet', function($sheet) use ($data)




Now this line of code here $sheet->getCell('A1')->setValue('first_name'); won’t work. Can someone help me figured this thing out?. Any help is muchly appreciated. TIA.

from Newest questions tagged laravel-5 – Stack Overflow

Related Posts

Codeigniter : Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE) in Laravel project

I’m getting following error: **Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE)** Note : It’s working in local but facing issue in production server. private…

Firebase receive notification while tab is active or on focus

What i want is to be able to perform an action when a user receives a notification while the browser is open and tab is active or…

Laravel’s alias loader does not find class

We have a legacy project that we cannot update and we need to make some changes in symfony’s Response.php in vendor. We have solved this by copying…

Laravel 5 – generic document management

I have a system where you can create different types of unique documents. For instance, one document is called Project Identified and this expects certain inputs. Originally,…

Laravel Nova limit the results in indexQuery

I ran intro a situation where I need to limit the results of a resource to only 3 results. To be more specific, based on the logged…

Auditoria en laravel 5.8 [closed]

Cómo puedo automatizar el registro de actividades de un usuario en laravel? Si un usuario ingresa a un app de laravel, debo guardar toda su actividas, a…

Leave a Reply

Your email address will not be published.