php - phpExcel in codeigniter -


I try to get the Excel file and cover it in PDF. I get success but I do not see the data and tell me that the data can not load in PDF

Here my code:

  // Our new PHPExcel library Load $ this- & gt; Load-> Library ('excel'); $ InputFileName = 'nameoffile'; $ Excel2 = PHPExcel_IOFactory :: createReader ('Excel5'); $ Excel2 = $ excel2- & gt; Load ($ inputfilename '.xls'); $ Excel2- & gt; SetActiveSheetIndex (0); Header ('pragma: public'); Header ('expiration: 0'); Header ('Cash-Control: Required-Modified, Post Check = 0, Pre-Check = 0'); Header ('content-type: application / force-download'); Header ('content-type: application / octet-stream'); Header ('content-type: application / download'); Header ("content-dispute: attachment; file name = to-template.pdf"); Header ('content-transfer-encoding: binary'); $ ObjWriter = PHPExcel_IOFactory :: createWriter ($ excel2, 'pdf'); $ ObjWriter- & gt; Save ('php: // output'); This is probably because  is not a PHPExcel_Writer_xls , however, A  PHPExcel_Writer_Excel5  is that you should use if you are trying to write BIFF-format  .xls  files  

However, your code shows The file names are "case-sensitive" so that you are trying to create a PDF author, so a PDF author needs to specify it in the upper case

 < Code> $ objWriter = PHPExc El_IOFactory :: createWriter ($ excel2), 'pdf');   

Edit

Do not use the same spreadsheet for your reader

  $ reader = PHPExcel_IOFactory :: createReader ('Excel5'); $ Spreadsheet = $ reader- & gt; Load ($ inputfilename '.xls'); Header ('content-type: application / pdf'); Header ('content-dispute: attachment; file name = "to-template.pdf"'); Header ('cache-control: max-age = 0'); // If you are serving in IE 9, then you may need a header for the following ('cache-control: max-age = 1'); // If you are serving IE on SSL, the header may be required for the following ('End: Mon, 26 July 1997 05:00:00 GMT'); // Date in the previous header ('Last-Modified:'. GMDET ('D, DM YH: I: S'). 'GMT'); // always modified the header ('cache-control: cache, must-revise'); // HTTP / 1.1 Header ('Prague: Public'); // http / 1.0 $ author = PHPExcel_IOFactory :: createWriter ($ spreadsheet, 'PDF'); $ Author- & gt; Save ('php: // output'); Die ();    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -