Cant Download Excel file When calling Laravel Cont

2019-05-15 05:15发布

问题:

Hi I am sending some data to laravel controller from angularjs and based on that data i want get data from sql table and download as excel file.But i am unable to download the file

Angular code

    $scope.sendSetField = function (selected_list) {        
    var arr = [];
    angular.forEach(selected_list, function(value, key){
        arr.push(key);
    });
    //console.log(selected_list);
    $http.post("http://localhost/maxo_ats_v1.00/dashboard/jobsDownload",arr)
   .then(function(response) {                 
    });

Laravel Controller :

     public function downloadJobsList(Request $request)
 {
   // $jobs = CnfFormField::select('id', 'name', 'email', 'created_at')->get();

  $jobs = Input::all();
 // return view('jobs.columnSelect',compact['data']);
  $data = Jobs::select($jobs)->get();

    Excel::create('Job', function($excel) use ($data) {
        $excel->sheet('mySheet', function($sheet) use ($data)
        {
            $sheet->fromArray($data);
        });
     })->download('xlsx');
 }

Route

Route::post('dashboard/jobsDownload','JobsController@downloadJobsList');