Open konsoft1 opened 3 months ago
Behavior is deliberate - Spreadsheet objects cannot be serialized or json encoded. See PR #3199.
But I never serialized or json encoded the Spreadsheet object. I just created the object.
Something is calling json_encode. But it is not called anywhere inside PhpSpreadsheet. I see the following external JSON calls in your stack trace.
#1 E:\Work\sanarena\project\invctrlpan\system\Format\JSONFormatter.php(42): json_encode(Array, 960, 512)
#2 E:\Work\sanarena\project\invctrlpan\system\API\ResponseTrait.php(357): CodeIgniter\Format\JSONFormatter->format(Array)
Is it possible that you have a Spreadsheet object in your array when this code is invoked?
This is:
What is the expected behavior?
I want no error execution.
What is the current behavior?
Fatal error: Uncaught PhpOffice\PhpSpreadsheet\Exception: Spreadsheet objects cannot be json encoded in E:\Work\sanarena\project\invctrlpan\app\ThirdParty\PHPOffice\PhpSpreadsheet\Spreadsheet.php:1519 Stack trace:
0 [internal function]: PhpOffice\PhpSpreadsheet\Spreadsheet->jsonSerialize()
1 E:\Work\sanarena\project\invctrlpan\system\Format\JSONFormatter.php(42): json_encode(Array, 960, 512)
2 E:\Work\sanarena\project\invctrlpan\system\API\ResponseTrait.php(357): CodeIgniter\Format\JSONFormatter->format(Array)
3 E:\Work\sanarena\project\invctrlpan\system\API\ResponseTrait.php(103): CodeIgniter\Debug\ExceptionHandler->format(Array)
4 E:\Work\sanarena\project\invctrlpan\system\Debug\ExceptionHandler.php(83): CodeIgniter\Debug\ExceptionHandler->respond(Array, 500)
5 E:\Work\sanarena\project\invctrlpan\system\Debug\Exceptions.php(163): CodeIgniter\Debug\ExceptionHandler->handle(Object(ReflectionException), Object(CodeIgniter\HTTP\IncomingRequest), Object(CodeIgniter\HTTP\Response), 500, 1)
6 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ReflectionException))
7 {main}
thrown in E:\Work\sanarena\project\invctrlpan\app\ThirdParty\PHPOffice\PhpSpreadsheet\Spreadsheet.phpon line1519
{ "title": "ErrorException", "type": "ErrorException", "code": 500, "message": "Uncaught PhpOffice\PhpSpreadsheet\Exception: Spreadsheet objects cannot be json encoded in E:\Work\sanarena\project\invctrlpan\app\ThirdParty\PHPOffice\PhpSpreadsheet\Spreadsheet.php:1519\nStack trace:\n#0 [internal function]: PhpOffice\PhpSpreadsheet\Spreadsheet->jsonSerialize()\n#1 E:\Work\sanarena\project\invctrlpan\system\Format\JSONFormatter.php(42): json_encode(Array, 960, 512)\n#2 E:\Work\sanarena\project\invctrlpan\system\API\ResponseTrait.php(357): CodeIgniter\Format\JSONFormatter->format(Array)\n#3 E:\Work\sanarena\project\invctrlpan\system\API\ResponseTrait.php(103): CodeIgniter\Debug\ExceptionHandler->format(Array)\n#4 E:\Work\sanarena\project\invctrlpan\system\Debug\ExceptionHandler.php(83): CodeIgniter\Debug\ExceptionHandler->respond(Array, 500)\n#5 E:\Work\sanarena\project\invctrlpan\system\Debug\Exceptions.php(163): CodeIgniter\Debug\ExceptionHandler->handle(Object(ReflectionException), Object(CodeIgniter\HTTP\IncomingRequest), Object(CodeIgniter\HTTP\Response), 500, 1)\n#6 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ReflectionException))\n#7 {main}\n thrown\n【Previous Exception】\nReflectionException\nClass \"Psr\SimpleCache\CacheInterface\" does not exist\n#0 E:\Work\sanarena\project\invctrlpan\app\ThirdParty\PHPOffice\PhpSpreadsheet\Settings.php(147): ReflectionClass->construct('Psr\\SimpleCache...')\n#1 E:\Work\sanarena\project\invctrlpan\app\ThirdParty\PHPOffice\PhpSpreadsheet\Settings.php(139): PhpOffice\PhpSpreadsheet\Settings::useSimpleCacheVersion3()\n#2 E:\Work\sanarena\project\invctrlpan\app\ThirdParty\PHPOffice\PhpSpreadsheet\Collection\CellsFactory.php(18): PhpOffice\PhpSpreadsheet\Settings::getCache()\n#3 E:\Work\sanarena\project\invctrlpan\app\ThirdParty\PHPOffice\PhpSpreadsheet\Worksheet\Worksheet.php(335): PhpOffice\PhpSpreadsheet\Collection\CellsFactory::getInstance(Object(PhpOffice\PhpSpreadsheet\Worksheet\Worksheet))\n#4 E:\Work\sanarena\project\invctrlpan\app\ThirdParty\PHPOffice\PhpSpreadsheet\Spreadsheet.php(409): PhpOffice\PhpSpreadsheet\Worksheet\Worksheet->construct(Object(PhpOffice\PhpSpreadsheet\Spreadsheet))\n#5 E:\Work\sanarena\project\invctrlpan\app\Controllers\Document\Download.php(151): PhpOffice\PhpSpreadsheet\Spreadsheet->__construct()\n#6 E:\Work\sanarena\project\invctrlpan\system\CodeIgniter.php(933): App\Controllers\Document\Download->getExportXml('8')\n#7 E:\Work\sanarena\project\invctrlpan\system\CodeIgniter.php(509): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Document\Download))\n#8 E:\Work\sanarena\project\invctrlpan\system\CodeIgniter.php(355): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)\n#9 E:\Work\sanarena\project\invctrlpan\system\Boot.php(325): CodeIgniter\CodeIgniter->run()\n#10 E:\Work\sanarena\project\invctrlpan\system\Boot.php(67): CodeIgniter\Boot::runCodeIgniter(Object(CodeIgniter\CodeIgniter))\n#11 E:\Work\sanarena\project\invctrlpan\public\index.php(56): CodeIgniter\Boot::bootWeb(Object(Config\Paths))\n#12 {main}", "file": "E:\Work\sanarena\project\invctrlpan\app\ThirdParty\PHPOffice\PhpSpreadsheet\Spreadsheet.php", "line": 1519, "trace": [ { "function": "shutdownHandler", "class": "CodeIgniter\Debug\Exceptions", "type": "->", "args": [] } ] }
What are the steps to reproduce?
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server: