使用挤出的行数据导出Excel

时间:2019-09-30 14:54:09

标签: laravel-excel

我试图根据数据量使列的大小和行大小保持固定,换行符。

当前: https://ap.imagensbrasil.org/image/captura-de-tela-de-2019-09-30-11-20-35.rGs1v3

我需要您这样返回: https://ap.imagensbrasil.org/image/captura-de-tela-de-2019-09-30-11-21-02.rGsO0H

我正在使用laravel excel 2.1,它必须是此版本

 \Excel::create($nomeRelatorio . '-' . date('d/m/Y__H:i:s'), function ($excel) use ($dadosContratos, $contDados) {
        $excel->sheet('Controle dos Aditivos', function ($sheet) use ($dadosContratos, $contDados) {
            $sheet->fromArray($dadosContratos, null, 'A1', true);

            $sheet->cell('A1:O1', function ($cells) {
                $cells->setBackground('#000000');
                $cells->setFontColor('#ffffff');
                $cells->setAlignment('center');

                $cells->setFont(array(
                    'family' => 'Calibri',
                    'size' => '12',
                    'bold' => true,
                ));
            });

            $sheet->getStyle('E2:' . 'E' . $contDados)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY);

            $sheet->setWidth(array(
                'A' => 10,
                'B' => 20,
                'C' => 30,
                'D' => 50,
                'E' => 100,
                'F' => 30,
                'G' => 30,
                'H' => 30,
                'I' => 30,
                'J' => 30,
                'K' => 30,
                'L' => 30,
                'M' => 30,
                'N' => 30,
                'O' => 30,
            ));

        });

        $excel->getDefaultStyle()
            ->getAlignment()
            ->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);

    })->export('xlsx');

数据来自数组。

$dadosContratos[] = ['Município' => $municipios];

0 个答案:

没有答案