导出为PDF时,将纸张方向设置为全屏

时间:2017-05-04 18:46:55

标签: laravel file pdf maatwebsite-excel

我正在尝试将图纸的方向导出到全屏,同时将其导出为pdf。这是我的代码

        Excel::create('Benchmark Constituents', function($excel) use ($Array_data) {

            $excel->setTitle('Benchmark Constituents');                     
            $excel->setDescription('File containing Benchmark Constituents');

        $excel->sheet('sheet1', function($sheet) use ($Array_data) {
            $sheet->setOrientation('landscape');                                                            
            $sheet->mergeCells('E1:G1');
            $sheet->cell('E1', function($cell) {
                $cell->setValue('Benchmark Constituents');
                $cell->setAlignment('center');
                $cell->setFontColor('#ffffff');
                $cell->setBackground('##000000');
                $cell->setFont(array(
                    'family'     => 'Calibri',
                    'size'       => '16',
                    'bold'       =>  true
                    ));
            });                                                                                         
            $sheet->fromArray($Array_data, null,"A3",true);
            $sheet->row(3, function($row) {
                $row->setBackground('#808080');
                $row->setFontColor('#ffffff');
            });
            $sheet->row(1, function($row) {
                $row->setBorder('none');
            });
            $sheet->row(2, function($row) {
                $row->setBorder('none');

            });
        });
    })->download('pdf');

我将此文件作为输出获取,因为页面宽度导致某些表列被隐藏:

image

1 个答案:

答案 0 :(得分:0)

尝试将页边距设置为0

// Set all margins to 0
$sheet->setPageMargin(0);

Document here