导出 Excel 时,报错:String exceeds Excel’s limit of 32:767 characters.
1、导出 Excel 时,报错:String exceeds Excel’s limit of 32:767 characters. 具体信息如下 如图1
[2024-05-15 06:51:22] local.ERROR: String exceeds Excel's limit of 32:767 characters. {"exception":"[object] (Vtiful\\Kernel\\Exception(code: 21): String exceeds Excel's limit of 32:767 characters. at E:\\wwwroot\\object\\app\\Services\\ExportService.php:104) [stacktrace] #0 E:\\wwwroot\\object\\app\\Services\\ExportService.php(104): Vtiful\\Kernel\\Excel->data(Array) #1 E:\\wwwroot\\object\\Modules\\Order\\Services\\OrderExportService.php(802): App\\Services\\ExportService->writeRows(Array) #2 E:\\wwwroot\\object\\Modules\\Order\\Services\\OrderExportService.php(329): Modules\\Order\\Services\\OrderExportService->exportCheck(Array, Array, '\\xE8\\xAE\\xA2\\xE5\\x8D\\x95\\xE5\\xAF\\xBC\\xE5\\x87\\xBA\\xE4\\xBB\\xBB...', 'e77f32cb-51f8-4...') #3 E:\\wwwroot\\object\\Modules\\Order\\Jobs\\OrderExportJob.php(53): Modules\\Order\\Services\\OrderExportService->exportOrderExcel(Array, Object(App\\Models\\JobStatus)) #4 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(36): Modules\\Order\\Jobs\\OrderExportJob->handle() #5 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #6 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure)) #7 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure)) #8 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(661): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL) #9 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Bus\\Dispatcher.php(128): Illuminate\\Container\\Container->call(Array) #10 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(141): Illuminate\\Bus\\Dispatcher->Illuminate\\Bus\\{closure}(Object(Modules\\Order\\Jobs\\OrderExportJob)) #11 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Modules\\Order\\Jobs\\OrderExportJob)) #12 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Bus\\Dispatcher.php(132): Illuminate\\Pipeline\\Pipeline->then(Object(Closure)) #13 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\CallQueuedHandler.php(124): Illuminate\\Bus\\Dispatcher->dispatchNow(Object(Modules\\Order\\Jobs\\OrderExportJob), false) #14 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(141): Illuminate\\Queue\\CallQueuedHandler->Illuminate\\Queue\\{closure}(Object(Modules\\Order\\Jobs\\OrderExportJob)) #15 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Modules\\Order\\Jobs\\OrderExportJob)) #16 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\CallQueuedHandler.php(126): Illuminate\\Pipeline\\Pipeline->then(Object(Closure)) #17 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\CallQueuedHandler.php(70): Illuminate\\Queue\\CallQueuedHandler->dispatchThroughMiddleware(Object(Illuminate\\Queue\\Jobs\\RedisJob), Object(Modules\\Order\\Jobs\\OrderExportJob)) #18 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Jobs\\Job.php(98): Illuminate\\Queue\\CallQueuedHandler->call(Object(Illuminate\\Queue\\Jobs\\RedisJob), Array) #19 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(425): Illuminate\\Queue\\Jobs\\Job->fire() #20 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(375): Illuminate\\Queue\\Worker->process('redis', Object(Illuminate\\Queue\\Jobs\\RedisJob), Object(Illuminate\\Queue\\WorkerOptions)) #21 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(173): Illuminate\\Queue\\Worker->runJob(Object(Illuminate\\Queue\\Jobs\\RedisJob), 'redis', Object(Illuminate\\Queue\\WorkerOptions)) #22 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Console\\WorkCommand.php(148): Illuminate\\Queue\\Worker->daemon('redis', 'export_queue', Object(Illuminate\\Queue\\WorkerOptions)) #23 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Console\\WorkCommand.php(131): Illuminate\\Queue\\Console\\WorkCommand->runWorker('redis', 'export_queue') #24 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(36): Illuminate\\Queue\\Console\\WorkCommand->handle() #25 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #26 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure)) #27 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure)) #28 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(661): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL) #29 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Command.php(183): Illuminate\\Container\\Container->call(Array) #30 E:\\wwwroot\\object\\vendor\\symfony\\console\\Command\\Command.php(326): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle)) #31 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Command.php(153): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle)) #32 E:\\wwwroot\\object\\vendor\\symfony\\console\\Application.php(1078): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #33 E:\\wwwroot\\object\\vendor\\symfony\\console\\Application.php(324): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Queue\\Console\\WorkCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #34 E:\\wwwroot\\object\\vendor\\symfony\\console\\Application.php(175): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #35 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Application.php(102): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #36 E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Console\\Kernel.php(155): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #37 E:\\wwwroot\\object\\artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #38 {main} "}
2、字符串超出了 Excel 的 32:767 个字符的限制。应该是尝试导出的某个字段的字符串长度超过了 Excel 单元格能存储的最大字符数限制。每个 Excel 单元格最多只能存储 32,767 个字符。
3、决定打印写入 Excel 的数据
Log::info( '$data', [ $data ] );
3、最后基于打印出的日志,找到了原因,某个字段的内容,其字符数量竟然有 7 万多个。已经远远超出了 32,767 个字符。如图2
近期评论