最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

背景

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

報(bào)錯(cuò)信息 如下:

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

問(wèn)題分析

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

解決方案

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

附錄

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

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

相關(guān)文章

最新評(píng)論

眉山市| 张家口市| 叶城县| 东丰县| 昭平县| 乌鲁木齐市| 靖西县| 汤阴县| 东丰县| 牡丹江市| 响水县| 兴隆县| 大理市| 永兴县| 泰来县| 泽普县| 东安县| 肇东市| 芮城县| 剑川县| 龙江县| 临夏县| 丽水市| 巴楚县| 昆山市| 古蔺县| 井陉县| 屯昌县| 都安| 荥阳市| 铜川市| 拜泉县| 夏邑县| 扶风县| 平山县| 宝山区| 禹城市| 筠连县| 花莲市| 健康| 浦江县|