douchuituo3032 2013-12-10 20:24
浏览 92
已采纳

使用phpexcel pdf渲染库的路径问题

i'm new to programming and i'm trying my best. So far i could install PHPExcel and could create a .xls file with content and it's working fine.

What i'm trying to do now is to put some content in a PDF file, with no success.

The error says that i should set the $renderName and the $renderNameLibrary, i did that.. so i don't understand what i'm doing wrong.

I use Codeigniter, so i copied PHPExcel folder into site/application/third_party/ folder and also copied the file PHPExcel.php in third_party.

Then on site/application/libraries/ i included this file: pdf.php and this is a snippet of what this file contains:

require_once APPPATH."/third_party/PHPExcel/IOFactory.php"; 

$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
$rendererLibrary = 'dompdf';
$rendererLibraryPath = dirname(__FILE__).'/libraries/dompdf' . $rendererLibrary;

i have installed the latest dompdf version in libraries/dompdf

is dompdf.php the file that i should set for $rendererLibrary?

the path where IOFactory.php is, is: site/application/third_party/PHPExcel/IOFactory.php

on my admin.php i have this function that i've created in order to test if pdf is working (using also the example 01simple-download-pdf.php from phpexcel documentation):

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');


}

I don't really know where is the error, can anyone please help me?

LAST EDIT: 11/12/2013

  • 写回答

1条回答 默认 最新

  • duannian3494 2013-12-11 09:44
    关注

    The $rendererLibraryPath value needs to be the path to the actual tcPDF library, not to PHPExcel's wrapper file....

    PHPExcel is capable of finding its own wrapper file, but has no idea where on your server you've installed the tcPDF library

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!