I just upgraded Laravel 5.4 to 5.5 and now I have to change all the coding that used the old Laravel-Excel.
I'm using php 7.2.25, Windows/Wamp.
I am trying to upload an excel file, get it's data, do lots of check and calculations on it (Not in the code yet) and then create a new excel file and give the user the Windows 'Save File' option.
- Not sure how to get the Windows save file window, don't see any explanation on the documentation.
1.1 If I can't get the Windows save file window, I'm not sure how to set the path to: My Documents\test for example.
- With the code I have, I get this error:
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_RECOVERABLE_ERROR) Type error: Return value of Maatwebsite\Excel\Sheet::mapArraybleRow() must be of the type array, string returned
My Import class code:
namespace App\Imports;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToCollection;
use App\Exports\TimesheetsExport;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Facades\Excel;
use App\User;
class TimesheetsImport implements ToCollection, WithHeadingRow
{
private $user;
public function __construct($param)
{
$this->user = $param;
}
public function collection(Collection $rows)
{
$data = new Collection([$this->user->fullName()]);
foreach ($rows as $row)
{
$data->put($row['date'], $row['in'], $row['out']);
}
return Excel::download(new TimesheetsExport($data), 'testtttt.xlsx');
My Export class:
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromCollection;
use Illuminate\Support\Collection;
class TimesheetsExport implements FromCollection
{
protected $rows;
public function __construct(Collection $rows)
{
$this->rows = $rows;
}
public function collection()
{
return $this->rows;
}
}
Can someone please help?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire