phpexcel 导出pdf文件乱码,该如何解决

WBOY
Release: 2016-06-13 12:09:55
Original
2104 people have browsed it

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 />
Copy after login

------解决思路----------------------
確定內容文字是UTF-8编码嗎?如果不是就要用iconv轉換編碼。
------解决思路----------------------
phpexcel生成pdf有一个重大的缺陷:excel中如果有图片,生成的pdf里不会保留,所以你用这个来生成pdf文件不是最好的方案!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!