使用phpexcel.pdf呈现库的路径问题


path issue for rendering libraries with phpexcel pdf

我是编程新手,正在尽我所能。到目前为止,我可以安装PHPExcel,并可以创建一个包含内容的.xls文件,它运行良好。

我现在想做的是把一些内容放在PDF文件中,但没有成功。

错误说我应该设置$renderName和$renderNameLibrary,我做到了。。所以我不明白我做错了什么。

我使用Codeigniter,所以我将PHPExcel文件夹复制到site/application/third_party/文件夹中,还将文件PHPExcel php复制到third_party中。

然后在site/application/librarys/i中包含了这个文件:pdf.php这是这个文件的一个片段:

require_once APPPATH."/third_party/PHPExcel/IOFactory.php"; 
$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
$rendererLibrary = 'dompdf';
$rendererLibraryPath = dirname(__FILE__).'/libraries/dompdf' . $rendererLibrary;

我已经在图书馆安装了最新的dompdf版本/dompdf-

dompdf.php是我应该为$rendererLibrary设置的文件吗?

IOFactory.php所在的路径为:site/application/threrd_party/PHPExcel/IOFactory.php

在我的admin.php上,我创建了这个函数来测试pdf是否有效(还使用phpexcel文档中的01simple-download-pdf.php示例):

public function exportToPdf(){
    $this->load->library('pdf');
    $this->pdf->getProperties()->setCreator("Maarten Balliauw")
                         ->setLastModifiedBy("Maarten Balliauw")
                         ->setTitle("PDF Test Document")
                         ->setSubject("PDF Test Document")
                         ->setDescription("Test document for PDF, generated using PHP classes.")
                         ->setKeywords("pdf php")
                         ->setCategory("Test result file");
    $this->pdf->setActiveSheetIndex(0)
        ->setCellValue('A1', 'Hello')
        ->setCellValue('B2', 'world!')
        ->setCellValue('C1', 'Hello')
        ->setCellValue('D2', 'world!');

    $filename=$rDate.'_Reporte_Usuarios_front'.'.pdf'; 
            header('Content-Type: application/pdf');
            header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell browser what's the file name
            header('Cache-Control: max-age=0'); //no cache
            // $objWriter = new PHPExcel_Writer_PDF($objPHPExcel);
            $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'PDF'); 
            $objWriter->setSheetIndex(0);
            $objWriter->save('php://output');

}

我真的不知道错误在哪里,有人能帮我吗?

最后一次编辑:2013年12月11日

$rendererLibraryPath值需要是实际tcPDF库的路径,而不是PHPExcel的包装文件的路径。。。。

PHPExcel能够找到自己的包装文件,但不知道您在服务器上的何处安装了tcPDF库