<?php
require_once "Classes/PHPExcel.php";
if(require ('Classes/PHPExcel/Settings.php')) {
echo 'well imported<br/>';
} else {
echo 'not imported<br>';
}
//require ('Classes/PHPExcel/Writer/PDF/DomPDF.php');
require ('Classes/DomPDF/Dompdf.php');
require_once ('Classes/PHPExcel/IOFactory.php');
include_once ('Classes/PHPExcel/Writer/Excel2007.php');
include_once ('Classes/PHPExcel/Writer/PDF.php');
$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
$rendererLibrary = 'domPDF0.6.0beta3';
//$rendererLibraryPath = dirname(__FILE__). 'libs/classes/dompdf' . $rendererLibrary;
$rendererLibraryPath = dirname(__FILE__). 'libs/classes/dompdf' . $rendererLibrary;
$tmpfname = "Ctest.xlsx";
$excelReader = PHPExcel_IOFactory::createReaderForFile($tmpfname);
$excelObj = $excelReader->load($tmpfname);
$worksheet = $excelObj->getSheet(0);
$lastRow = $worksheet->getHighestRow();
echo "<table>";
for ($row = 1; $row <= $lastRow; $row++) {
echo "<tr><td>";
echo $worksheet->getCell('A'.$row)->getValue();
echo "</td><td>";
echo $worksheet->getCell('B'.$row)->getValue();
echo "</td><tr>";
}
echo "</table>";
$objPHPExcel = new PHPExcel();
$objPHPExcel->getActiveSheet()->setTitle('Orari');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
$objWriter->setSheetIndex(0);
$objWriter->save('Ctest.pdf');
?>
致命错误:未捕获PHPExcel_Writer_Exception:PDF渲染库 尚未定义。在 /opt/lampp/htdocs/PHPExcelTestExportPDF/Classes/PHPExcel/Writer/PDF.php:48 堆栈跟踪:#0 /opt/lampp/htdocs/PHPExcelTestExportPDF/Classes/PHPExcel/IOFactory.php(139): PHPExcel_Writer_PDF-> __ construct(Object(PHPExcel))#1 /opt/lampp/htdocs/PHPExcelTestExportPDF/phpexc.php(35): PHPExcel_IOFactory :: createWriter(Object(PHPExcel),'PDF')#2 {main} 扔进去 /opt/lampp/htdocs/PHPExcelTestExportPDF/Classes/PHPExcel/Writer/PDF.php 在第48行