Lilov Lilov - 1 year ago 126
MySQL Question

Control excel export

So basically got laravel project and got to export tables in excel. I'm using this for the export. Till now i only export from array or in my case.

public function exportGames()
$export = Games::all();
Excel::create('Games Data', function($excel) use($export){
$excel->sheet('Games', function($sheet) use($export){

This however returns full table data, which include some field I to be gone (timestamps etc.). Also relational tables is not possible to display (only in the actual table on the page). Spend hours in the documentation still don't understand how to do it. Wanna rip my hair off. How do modify columns to export. Thanks in advice.

Answer Source

Seems simple enough:

$export = Games::select(['client_game_id', 'client_game_name', 'gameid', 'description', 'game_type', 'db_name', 'short_name'])->get();

You'll only see those columns in your exported XLS file.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download