Laravel-excel: set column width on view blade.

Created on 22 May 2014  路  8Comments  路  Source: Maatwebsite/Laravel-Excel

I export excel by blade view.
could i set column width on it?

Most helpful comment

What version is it fixed on?
Using 2.1 and cant set width's in either blade or excel.

All 8 comments

I am difficult to set any styling at 2 places (excel and view).
If i am base on view, it should be can set only view.

Will be something for future release.

Hello @Maatwebsite, I am trying to set column width but without success. Is that even possible when exporting from Blade view?

I have something like this

        Excel::create($filename, function($excel) use ($sheet_data) {
            $excel->sheet('Worksheet', function($sheet) use ($sheet_data) {
                $sheet->loadView('excel_template', $sheet_data);

                // Set width
                $sheet->setWidth('A', 100);
                $sheet->setWidth('B', 200);
                $sheet->setWidth('C', 300);

                // Set column format
                $sheet->setColumnFormat(array(
                    'D' => '#,##0.00'
                ));
            });

        })->download('xls');

Setting column width has no effect, but column format works as expected.

That should work. I will have a look at it.

Fixed

What version is it fixed on?
Using 2.1 and cant set width's in either blade or excel.

If you are exporting form view you can directly use

style="word-wrap:break-word"

Just make sure your Export class is not implementing ShouldAutoSize

Was this page helpful?
0 / 5 - 0 ratings