Cant Download Excel file When calling Laravel Controller from AngularJS

瘦欲@ 提交于 2019-12-10 10:07:34

问题


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');

来源:https://stackoverflow.com/questions/45077081/cant-download-excel-file-when-calling-laravel-controller-from-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!