laravel excel export添加额外的标题行

时间:2018-02-07 20:55:30

标签: php excel laravel-excel

这是我的代码:

   Excel::create($file_name, function ($excel) use ($data, $sheet_name) {
        $excel->sheet($sheet_name, function ($sheet) use ($data) {


            $data[] = ['id', 'customer', 'email', 'total', 'created_at'];
            $data[] = ['1', '2', '3', '4', '5'];
            $data[] = ['11', '2', '3', '4', '5'];
            $data[] = ['111', '2', '3', '4', '5'];
            $data[] = ['1111', '2', '3', '4', '5'];


            $sheet->fromArray($data, null, 'A1', true, true);
            });

        // Set the title
         $excel->setTitle('Our new awesome title');
        // Chain the setters
        $excel->setCreator('test')->setCompany('test');

        // Call them separately
        $excel->setDescription('A demonstration to change the file properties');

    })->export($type);

这是我的输出

enter image description here

为什么在顶行添加0,1,2,3,4?

请帮助谢谢

1 个答案:

答案 0 :(得分:1)

而不是

 $sheet->fromArray($data, null, 'A1', true, true);

应该是这个

$sheet->fromArray($data, null, 'A1', false, false);