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

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

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题