0
votes

how could i transform the file to pdf

i already tried change extension name but the image will disappear and excel format will shift

so is there any good idea can transform the file and at the same time could save the image and format?

here is my export code my maatwebsite package does not have the create method.

    public function export(Order $order)
    {

        return Excel::download(new OrderExport($order), $order->no.'.xlsx');
        
    }

and the excel file will look like excel file

if i transform it will be likeenter image description here

1

1 Answers

0
votes

We had a similar problem but with word files. We came to the conclusion that using the lowriter from LibreOffice will do the trick.

Option 1

In addition we used the use TitasGailius\Terminal\Terminal; library for easy Terminal use.

  • $export_path is the path where your excel file is
  • $file is the name of your file

$resp = Terminal::in($export_path)->run('lowriter --headless --convert-to pdf '.$file);

Option 2

Using some built in functionality of the Excel package.

Excel::create('Filename', function($excel) {
})->export('xls');

https://docs.laravel-excel.com/2.1/export/export.html