使用PHPExcel TCPDF生成PDF时从右侧切割单元格

时间:2015-11-26 14:42:42

标签: php csv pdf phpexcel tcpdf

我正在使用CSV和PDF格式的PHPExcel生成报告。

CSV正在生成完美,但PDF表现得很笨拙。

首先,图片未以PDF格式显示。其次,细胞正在从PDF右侧切割。

以下是两者的截图。

CSV: enter image description here

PDF: enter image description here

这是代码

创建PDF写入

$csv = new PHPExcel();    
$rendererName = PHPExcel_Settings::PDF_RENDERER_TCPDF;
$rendererLibrary = 'tcpdf';
$rendererLibraryPath = _LIBRARIES_PATH_."/".$rendererLibrary;
PHPExcel_Settings::setPdfRenderer($rendererName,$rendererLibraryPath); 
$csvWriter = PHPExcel_IOFactory::createWriter($csv, "PDF");

写图像

$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Company LOGO');
$objDrawing->setDescription('Company LOGO');
$objDrawing->setPath($companyLogo);
$objDrawing->setWidthAndHeight(150,90);
$objDrawing->setResizeProportional(true);
$objDrawing->setCoordinates('E1');
$objDrawing->setWorksheet($csv->getActiveSheet());

写入值

$csv->getActiveSheet()->SetCellValue('A5', 'Sr.');
$csv->getActiveSheet()->SetCellValue('B5', 'User ID');
$csv->getActiveSheet()->SetCellValue('C5', 'Name');
$csv->getActiveSheet()->SetCellValue('D5', 'Total Hrs Worked');
$csv->getActiveSheet()->SetCellValue('E5', 'Total Break Duration');
$csv->getActiveSheet()->SetCellValue('F5', 'Rate/Hr');
$csv->getActiveSheet()->SetCellValue('G5', 'Total Cost');

保存到最后

$csvWriter->save("php://output");

0 个答案:

没有答案