这是我的应用程序如何从我的应用程序生成报告(excel文件):
一个月一次
public function collection()
{
return Actividad::whereMonth('fecha_inicio', '12')
->whereYear('fecha_inicio', '2022')
->orderBy('servicio_id', 'ASC')
->with('servicio')
->get();
}
public function headings(): array
{
return [
'SERVICIO',
'DESCRIPCION',
];
}
public function map($actividad) : array
{
$nombre = [];
$descripcion = [];
foreach($actividad as $activity){
// dump($actividad);
$nombre[]=$actividad->descripcion;
foreach($actividad->servicio as $key => $servicio){
$descripcion = $actividad->servicio->nombre;
}
}
return [
[
$nombre[0],
$descripcion,
'',
'',
],
];
}
屏幕截图显示了4行中的4条记录,我想尝试转换一行中唯一单元格中的4条记录,如以下示例:
1条答案
按热度按时间lymnna711#
您可以在视图中轻松完成此操作。https://docs.laravel-excel.com/3.1/exports/from-view.html
resources/views/exports/your_view.blade.php
或者使用
rowspan
属性获取电子表格中的分组单元格