I try to use maatwebsite Laravel excel 2.1 to replace my old phpexcel script.
With php excel, I query my bdd and loop inside.
Each line of data as his own data + parents data so two or more line can have same value.
So I loop through each data and write the value row by row. If parents values are the same as before, I merge the cell.
At the end, I have merge all cells that have the same values.
How can I do something like this on laravel-excel ??
At the moment I gather all the data inside an array and use this code to export :
Excel::load('excel\recap.xls', function($excel) use($array) {
$excel->sheet('Copro', function($sheet) use($array) {
$sheet->fromArray($array, null, 'A9', false);
foreach ($sheet as $row) {
$sheet->setCellValue($row, 'some value');
}
});
})->export('xls');
For example, $array can be like this :
array:2 [
0 => array:8 [
"Batiment" => "Unique"
"N° du lot" => 7
"Étage" => "1e étage"
"Fraction" => "Parking 0.35"
"Surface" => "11.500"
"Coefficient" => "0.350"
"Surface pondérée" => "4.025"
"Quote-part" => "635.961"
]
1 => array:8 [
"Batiment" => "Unique"
"N° du lot" => 8
"Étage" => "1e étage"
"Fraction" => "Principal"
"Surface" => "65.850"
"Coefficient" => "0.903"
"Surface pondérée" => "59.265"
"Quote-part" => "9364.039"
]
]
So here I want to merge "Batiment" and "Etage" columns, but it can be else columns and for a lot of rows.
Someone know how to do this ?
Thank for your help.