I'm blocking to export an excel file from a table on laravel here's my controller :
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
use Excel;
class ExportExcelController extends Controller
{
function Export()
{
$customer_data = DB::table('qualys')->get();
return view('export_excel')->with('customer_data', $customer_data);
}
function excel()
{
$customer_data = DB::table('qualys')->get();
$customer_array[] = array('ip','qid');
// dd($customer_data);
foreach($customer_data as $customer)
{
// dd($customer);
$customer_array[] = array(
'ip' => $customer->qid,
'qid' => $customer->ip
);
}
Excel::download('customer_data.xlsx', 'customer_data.xls');
// Excel::download('customer data', function($excel) use ($customer_array) {
// $excel->setTitle('customer Data');
// $excel->sheet('Customer Data', function($sheet) use ($customer_array)
// {
// $sheet->fromArray($customer_array, null, 'A1', false, false);
// });
// })->download('xls', 'test');
}
}
I'm blocked at line 29 level, I can't get the file back, here's the following error:
Argument 2 passed to Maatwebsite\Excel\Excel::download() must be of the type string, object given, called in /var/www/html/qualys/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 223
I have tested several "code" but nothing works:( can you help me plz? cordially.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire