时间:2021-07-01 10:21:17 帮助过:3人阅读
require_once 'excel/PHPExcel.php';
$objPHPExcel = PHPExcel_IOFactory::load( "template.xls" );
$objPHPExcel->setActiveSheetIndex(0);
$objWorksheet = $objPHPExcel->getActiveSheet();
//写内容
$objWorksheet->getCell("C1")->setValue("test");
//假如图片
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('stamp');
$objDrawing->setDescription("aaaa");
$objDrawing->setPath("images/p1.jpg");
$objDrawing->setCoordinates('M1');
$objDrawing->setOffsetX(25);
$objDrawing->setRotation(36);
$objDrawing->setHeight(73);
$objDrawing->getShadow()->setVisible(true);
$objDrawing->getShadow()->setDirection(45);
$objDrawing->setWorksheet($objWorksheet);
$objWorksheet->setTitle('Simple');
ob_end_clean();
header('Content-Type: application/pdf');
header('Content-Disposition: attachment;filename="detail.pdf"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
$objWriter->save('php://output');
exit;