- [*] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
<?php
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf;
use Controller\Controller;
class v3 extends Controller
{
private static $excel_folder = "assets/uploads/pdf/";
function __construct()
{
$this->config();
$this->request = $this->helper('request');
$this->db_users = $this->model('db_users');
$this->db_tims = $this->model('db_tims');
$this->request = $this->helper('request');
}
public function read()
{
$read_file = "assets/uploads/xls/sample.xls";
$upload_file = "assets/uploads/pdf/sample123.pdf";
$read = IOFactory::createReader("Xls");
$spreadsheet = $read->load($read_file);
$writer = IOFactory::createWriter($spreadsheet, 'Mpdf');
$writer->save($upload_file);
}
}
Output:
Fatal error: Uncaught Error: Class "Mpdf\Mpdf" not found in C:\xampp\htdocs\tims\vendor\phpExcel\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Pdf\Mpdf.php:23
Stack trace: #0 C:\xampp\htdocs\tims\vendor\phpExcel\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Pdf\Mpdf.php(44):
PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf->createExternalWriterInstance(Array) #1 C:\xampp\htdocs\tims\app\api\v3.php(148):
PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf->save('assets/uploads/...') #2 C:\xampp\htdocs\tims\app\controllers\auth.php(46): v3->read(Array) #3 [internal function]:
auth->api('v3', 'read') #4 C:\xampp\htdocs\tims\routes\App.php(44): call_user_func_array(Array, Array) #5 C:\xampp\htdocs\tims\index.php(33):
App\App->__construct(NULL, NULL, Array) #6 {main} thrown in C:\xampp\htdocs\tims\vendor\phpExcel\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Pdf\Mpdf.php on line 23
If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.
What features do you think are causing the issue
[ ] Reader
[*] Writer
[ ] Styles
[ ] Data Validations
[ ] Formula Calculations
[ ] Charts
[ ] AutoFilter
[ ] Form Elements
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
Which versions of PhpSpreadsheet and PHP are affected?
This is:
What is the expected behavior?
What is the current behavior?
What are the steps to reproduce?
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
Output:
If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.
What features do you think are causing the issue
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
Which versions of PhpSpreadsheet and PHP are affected?