php技巧

关注公众号 jb51net

关闭
首页 > 网络编程 > PHP编程 > php技巧 > PHPExcel导出Excel报错

PHPExcel导出Excel报错:PHPExcel_IOFactory::load()的解决方案

作者:moTzxx

这篇文章主要介绍了PHPExcel导出Excel报错:PHPExcel_IOFactory::load()的解决方案,文中有详细的问题分析和解决方法供大家参考,具有一定的参考价值,需要的朋友可以参考下

背景

报错信息 如下:

{
	"name": "PHP Notice",
	"message": "iconv(): Detected an illegal character in input string",
	"code": 8,
	"type": "yii\\base\\ErrorException",
	"file": "/usr/share/nginx/html/ycsh_automat/Classes/PHPExcel/Shared/String.php",
	"line": 490,
	"stack-trace": [
	  "#0 [internal function]: yii\\base\\ErrorHandler->handleError(8, 'iconv(): Detect...', '/usr/share/ngin...', 493, Array)", 
	  "#1 /usr/share/nginx/html/ycsh_automat/Classes/PHPExcel/Shared/String.php(490): iconv('CP1252', 'UTF-8', '\\xE8\\xAE\\xA2\\xE5\\x8D\\x95\\xE5\\x88\\x97\\xE8\\xA1\\xA8\\x00\\x00\\x00...')", 
	  "#2 /usr/share/nginx/html/ycsh_automat/Classes/PHPExcel/Reader/Excel5.php(1362): PHPExcel_Shared_String::ConvertEncoding('\\xE8\\xAE\\xA2\\xE5\\x8D\\x95\\xE5\\x88\\x97\\xE8\\xA1\\xA8\\x00\\x00\\x00...', 'UTF-8', 'CP1252')", 
	  "#3 /usr/share/nginx/html/ycsh_automat/Classes/PHPExcel/Reader/Excel5.php(633): PHPExcel_Reader_Excel5->readSummaryInformation()", 
	  "#4 /usr/share/nginx/html/ycsh_automat/Classes/PHPExcel/IOFactory.php(192): PHPExcel_Reader_Excel5->load('/usr/share/ngin...')", 
	  "#5 /usr/share/nginx/html/ycsh_automat/common/services/ExcelMzService.php(154): PHPExcel_IOFactory::load('/usr/share/ngin...')", 
	  "#6 /usr/share/nginx/html/ycsh_automat/common/models/ExportTask.php(306): common\\services\\ExcelMzService->cronCreateExportFile(Array, Array, '/usr/share/ngin...', Array, '\\xE8\\xAE\\xA2\\xE5\\x8D\\x95\\xE5\\x88\\x97\\xE8\\xA1\\xA8')", 
	  "#7 /usr/share/nginx/html/ycsh_automat/api/controllers/CronController.php(54): common\\models\\ExportTask::execExportTask(Object(common\\models\\ExportTask), 1, '{\"search_params...')", 
	  "#8 [internal function]: api\\controllers\\CronController->actionRunExportTask()", 
	  ...
}

问题分析

解决方案

修改文件 Classes\PHPExcel\Shared\String.php 的 ConvertEncoding() 方法的的第一个条件判断,如下

附录

以上就是PHPExcel导出Excel报错:PHPExcel_IOFactory::load()的解决方案的详细内容,更多关于PHPExcel导出Excel报错的资料请关注脚本之家其它相关文章!

您可能感兴趣的文章:
阅读全文