I am trying to convert an Excel file to an array using the latest version of Laravel-Excel (3.1.9)
The code below will download the file:
return Excel::download(new SalesOrderExport('columns'),'test.xlsx')
But I need to convert it to get an array only. I don't want to store this Excel data in a database at this point.
I tried with the code below but it did not work as the load
method is not available in version 3.
Excel::load($request->file('sampledata'), function ($reader) {
return response()->json($reader);
});
Please share your thoughts on how to get an array from Excel.
Here is how I achieved this:
In my UsersImport class: namespace App\Imports;
And in controller:
I hope it helps you.
You should try this:
1) Create Import File using below command.
2) Inside TestImport make changes like this:
3) In Controller make changes like this:
I and @narayan tried hard to make requested excel file into array. Now I am able to get array properly with below code
In my SalesOrderExport class I have default function only, which is required as abstract method.
My Controller code
And in HTML
I already created this export by
Attaching related images