php - Export database table into EXCEL in laravel
Get the solution ↓↓↓Solution:
When i run this, excel file..
I'm assuming you mean call a controller function with a web route. Something like..
Route::get('/your/path', 'BusinessController@export')->name('export');
i want to export database table data into excel file.
You can use Maatwebsite/Excel 2.1.0 for this.
BusinessController:
use App\Approvedemand;
public function export()
{
$data = App\Approvedemand::all();
return Excel::create('Approve Demand'), function($excel) use ($data) {
$excel->sheet('Sheetname', function($sheet) use ($data)
{
$sheet->fromArray($data);
});
})->export('xls');
}
This is just a basic example. You'd obviously want to include some validation here.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: your system folder path does not appear to be set correctly. please open the following file and correct this: index.php
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.