1

I make a report with maatwebsite and download it to xls and works fine, but now I need to export it to PDF, so when it exports to PDF only returns the first page, even if has multiple sheets.

 Excel::create('name', function ($excel) {
     foreach ($categories as $value) {
          $excel->sheet($value['name'], function($sheet) {
            ...
          });
     }
 })->download('pdf');

How can I see all pages? I'm using laravel 4.2, maatwebsite/excel 1.3.0 and mpdf 6.0.0

Alexander
  • 2,925
  • 3
  • 33
  • 36
Nesuferit
  • 21
  • 1
  • 5

3 Answers3

2

Fetch $data and put $filename = "new.pdf"

 $filename = "new.pdf";
 Excel::download( new ExportOrder( $data ), $filename);
Prajwol KC
  • 398
  • 6
  • 13
1

If you read the documentation you should use ->export('pdf') instead of ->download('pdf').

Please try it and return with the result.

Text from the documentation:
To export files to pdf, you will have to include "dompdf/dompdf": "~0.6.1", "mpdf/mpdf": "~5.7.3" or "tecnick.com/tcpdf": "~6.0.0" in your composer.json and change the export.pdf.driver config setting accordingly.

SebHallin
  • 881
  • 6
  • 11
  • I had already done , with the same result. Only shows the first page. – Nesuferit Apr 07 '15 at 18:17
  • I tried dompdf/dompdf ~0.6.1, mpdf/mpdf ~5.7.3, mpdf/mpdf 6.0.0 and tecnick.com/tcpdf ~6.0.0. Same result. T_T – Nesuferit Apr 07 '15 at 18:31
  • I don't think I can help you with this, I would probably use mpdf without maatwebsite. It got quite easy [documentation](http://mpdf1.com/manual/) and it will probably be faster to use less functions (only mpdf instead of both mpdf and maatwebsite). – SebHallin Apr 07 '15 at 18:36
  • That's what I'm going to do, make another report but now with mPHP for the php report. Thanks for answer. – Nesuferit Apr 07 '15 at 18:45
  • I found [this issue](https://github.com/Maatwebsite/Laravel-Excel/issues/386) on github. – SebHallin Apr 07 '15 at 19:05
  • I have another (hopefully possible) solution, if you use the maatwebsite function `->store` instead (move the foreach outside the `Excel::create`), and then combine them with [this solution](http://stackoverflow.com/a/4795472/4637793), it could work? (it would probably take more time to download the pdf-report but it could be faster to write the code) – SebHallin Apr 07 '15 at 19:17
1

I generate the same question on maatwebsite github. I did this and it works.

https://github.com/Maatwebsite/Laravel-Excel/issues/386

Nesuferit
  • 21
  • 1
  • 5