• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pdf creation using PhpSpreadsheet

#1
I am trying to create PDF using PhpSpreadsheet with CI 3.1.11 but it gives error as per attachment. So is it necessary to merge PhpSpreadsheet with mPDF.

I used below code

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

require(APPPATH.'/third_party/PhpSpreadsheet/vendor/autoload.php');
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf;
class Exports extends CI_Controller {

function __construct()
  {
      parent::__construct();
  }

public function  index()
{
$spreadsheet = new Spreadsheet();
      $htmlString = '<table>
                  <tr>
                      <td>Hello World</td>
                  </tr>
                  <tr>
                      <td>Hello<br />World</td>
                  </tr>
                  <tr>
                      <td>Hello<br>World</td>
                  </tr>
              </table>';

      $reader = new \PhpOffice\PhpSpreadsheet\Reader\Html();
      $spreadsheet = $reader->loadFromString($htmlString);
     
      $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Mpdf');
      $writer->save("demo.pdf");
}

}


Attached Files Thumbnail(s)
   
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.