I have an Excel file that is stored in my server with some Dynamic Data. I want to Edit the Data in The Sheet then Download the Excel with Keeping the sheet format .
I am Already Editing the Data in Excel but I can’t keep the original style of the Sheet.
i am using maatwebsite/excel package with Laravel 8.
my controller code:
public function generateArtisanalFile(Request $request){
$lins=new ArtisanalImport();
$data= Excel::import($lins,public_path('storage/delivered/CI-model.xlsx'));
$export = new AsrisanalFileGenerator($lins->data);
return Excel::download($export, 'model.xlsx');
}
The Import Class :
class ArtisanalImport implements ToCollection
{
public $data;
public function collection(Collection $rows)
{
$rows[7][1]='karim El Hajjami';
$rows[3][0]='Delivered';
$this->data=$rows;
}
}
this is the Export Class:
class AsrisanalFileGenerator implements FromCollection
{
public $data;
public function __construct($data){
$this->data=$data;
}
public function collection()
{
return $this->data;
}
}