vendredi 30 juin 2017

Laravel 5.3 excel package

I installed the Excel package in my laravel installation it's work fine but only problem is I don't know how to create header of the excel data does anyone know?

public function Exportcsv(Request $recuestdata){
    $data = $recuestdata['row'];

    $export_paye[] =[
        'Order Number',
        'Customer Email',
        'Delivery Date',
        ];
    $myFile = Excel::create('Order export', function($excel) use ($export_paye,$data) {
    // Set the spreadsheet title, creator, and description
    $excel->setTitle('Order export');
    $excel->setDescription('Order export');
       // Build the spreadsheet, passing in the payments array
       $excel->sheet('sheet1', function($sheet) use ($data) {
           $sheet->fromArray($data , null, 'A1', false, false);
       });
   });

  $myFile = $myFile->string('xlsx');

    $response =  array(
       'name' =>"test.xlsx", //no extention needed
       'file' => "data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,".base64_encode($myFile) //mime type of used format
    );

    return response()->json($response);
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2tqKFPD
via IFTTT

Aucun commentaire:

Enregistrer un commentaire