3

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.