Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Help me i want to save excel in pdf format The code:

include_once 'Classes/PHPExcel.php';
/** PHPExcel_IOFactory */
require_once ('Classes/PHPExcel/IOFactory.php');
include_once ('Classes/PHPExcel/Writer/Excel2007.php');
include_once ('Classes/PHPExcel/Writer/PDF.php');

include_once ('Classes/PHPExcel/Writer/PDF/DomPDF.php');


$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
//$rendererLibrary = 'tcPDF5.9';
//$rendererLibrary = 'mPDF5.4';
$rendererLibrary = 'domPDF0.6.0beta3';
$rendererLibraryPath = '/' . $rendererLibrary;
$objPHPExcel->getActiveSheet()->setTitle('Orari');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
$objWriter->setSheetIndex(0);
$objWriter->save('esp.pdf');

I want to save in pdf format, but when i try to save i have an error response from phpexcel: Fatal error: Uncaught exception 'PHPExcel_Writer_Exception' with message 'Unable to load PDF Rendering library' in C:xampphtdocsfservClassesPHPExcelWriterPDFDomPDF.php:34 Stack trace: #0 C:xampphtdocsfservesportatore.php(190): include_once() #1 C:xampphtdocsfservindex.php(44): include('C:xampphtdocs...') #2 {main} thrown in C:xampphtdocsfservClassesPHPExcelWriterPDFDomPDF.php on line 34

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
704 views
Welcome To Ask or Share your Answers For Others

1 Answer

You need DomPDF for rendering the PDF. Check if you have the DomPDF library, otherwise download and implement it as follow:

$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
$rendererLibrary = 'domPDF0.6.0beta3';
$rendererLibraryPath = dirname(__FILE__). 'libs/classes/dompdf' . $rendererLibrary;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...