Maison > Article > développement back-end > phpexcel 导出pdf文件乱码,该如何解决
phpexcel 导出pdf文件乱码
代码过程是,读取模板文件template.xls。写入对应内容,导出pdf文件。template.xls文件内容带有表格和日文。 个人认为是没有字体的原因,但是如何对应,望大虾告知!!!
<br />require_once 'excel/PHPExcel.php';<br /><br />$objPHPExcel = PHPExcel_IOFactory::load( "template.xls" );<br />$objPHPExcel->setActiveSheetIndex(0);<br />$objWorksheet = $objPHPExcel->getActiveSheet();<br />//写内容<br />$objWorksheet->getCell("C1")->setValue("test");<br />//假如图片<br />$objDrawing = new PHPExcel_Worksheet_Drawing();<br />$objDrawing->setName('stamp');<br />$objDrawing->setDescription("aaaa");<br />$objDrawing->setPath("images/p1.jpg");<br />$objDrawing->setCoordinates('M1');<br />$objDrawing->setOffsetX(25);<br />$objDrawing->setRotation(36);<br />$objDrawing->setHeight(73);<br />$objDrawing->getShadow()->setVisible(true);<br />$objDrawing->getShadow()->setDirection(45);<br />$objDrawing->setWorksheet($objWorksheet);<br /><br />$objWorksheet->setTitle('Simple');<br /><br />ob_end_clean();<br />header('Content-Type: application/pdf');<br />header('Content-Disposition: attachment;filename="detail.pdf"');<br />header('Cache-Control: max-age=0');<br />$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');<br />$objWriter->save('php://output');<br />exit;<br />