亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

PHPExcel導(dǎo)出Excel報錯:PHPExcel_IOFactory::load()的解決方案

 更新時間:2023年11月29日 09:50:21   作者:moTzxx  
這篇文章主要介紹了PHPExcel導(dǎo)出Excel報錯:PHPExcel_IOFactory::load()的解決方案,文中有詳細(xì)的問題分析和解決方法供大家參考,具有一定的參考價值,需要的朋友可以參考下

背景

  • 近期在做 excel文件數(shù)據(jù)導(dǎo)出時,遇到如下報錯: iconv(): Detected an illegal character in input string
  • 場景:計(jì)劃任務(wù)后臺,分步導(dǎo)出 大數(shù)據(jù) excel文件
  • 發(fā)現(xiàn)在加載文件時,會有報錯

報錯信息 如下:

{
	"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()", 
	  ...
}

問題分析

  • 根據(jù)詳細(xì)報錯信息,可以知道,是執(zhí)行 PHPExcel_IOFactory::load() 方法時,因?yàn)槲募幋a問題造成程序中斷
  • 業(yè)務(wù)場景中,即在分步追加 excel文件數(shù)據(jù),加載文件名時,識別轉(zhuǎn)碼有誤
  • 繼而定位到 Classes\PHPExcel\Shared\String.php 的 ConvertEncoding() 方法的的第一個條件判斷不滿足

解決方案

修改文件 Classes\PHPExcel\Shared\String.php 的 ConvertEncoding() 方法的的第一個條件判斷,如下

附錄

  • 網(wǎng)上的經(jīng)驗(yàn),基本為 php iconv() : Detected an illegal character in input string, 測試發(fā)現(xiàn)都無法解決我的問題
  • 重點(diǎn)提示:當(dāng)前報錯,在 windows 環(huán)境中,不會報錯,只有上傳到 Linux 服務(wù)器,才會有報錯!

以上就是PHPExcel導(dǎo)出Excel報錯:PHPExcel_IOFactory::load()的解決方案的詳細(xì)內(nèi)容,更多關(guān)于PHPExcel導(dǎo)出Excel報錯的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • PHP實(shí)現(xiàn)的增強(qiáng)性mhash函數(shù)

    PHP實(shí)現(xiàn)的增強(qiáng)性mhash函數(shù)

    這篇文章主要介紹了PHP實(shí)現(xiàn)的增強(qiáng)性mhash函數(shù),使用默認(rèn)mhash函數(shù)時報錯,找到了兩個解決方法,需要的朋友可以參考下
    2015-05-05
  • 使用PHPMailer實(shí)現(xiàn)郵件的實(shí)時發(fā)送功能

    使用PHPMailer實(shí)現(xiàn)郵件的實(shí)時發(fā)送功能

    這篇文章主要為大家詳細(xì)介紹了如何使用PHPMailer 實(shí)現(xiàn)一個接收詢盤并實(shí)時同步到指定郵箱的功能,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下
    2023-12-12
  • 關(guān)于PHP模板Smarty的初級使用方法以及心得分享

    關(guān)于PHP模板Smarty的初級使用方法以及心得分享

    本篇文章是對PHP模板Smarty的初級使用方法以及心得進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06
  • 最新評論