From 420e54a37dfd627ecf97ccf357bd0c6a82626bcd Mon Sep 17 00:00:00 2001 From: Looly Date: Tue, 27 May 2025 12:20:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`ExcelPicUtil`=E4=B8=AD?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E7=9A=84=E7=A9=BA=E6=8C=87=E9=92=88=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++- .../src/main/java/cn/hutool/poi/excel/ExcelPicUtil.java | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3fe6874b..46e627212 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ # 🚀Changelog ------------------------------------------------------------------------------------------------------------- -# 5.8.39(2025-05-23) +# 5.8.39(2025-05-27) ### 🐣新特性 * 【ai 】 增加SSE流式返回函数参数callback,豆包、grok新增文生图接口,豆包生成视频支持使用model @@ -14,6 +14,7 @@ * 【core 】 修复`CharsequenceUtil`toLowerCase方法拼写错误(issue#3941@Github) * 【core 】 修复`UUID`equals的问题,改为final类(issue#3948@Github) * 【core 】 修复`Money`中金额分配的问题bug(issue#IC9Y35@Gitee) +* 【poi 】 修复`ExcelPicUtil`中可能的空指针异常 ------------------------------------------------------------------------------------------------------------- # 5.8.38(2025-05-13) diff --git a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelPicUtil.java b/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelPicUtil.java index 1df57cd6f..4a54ab27f 100644 --- a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelPicUtil.java +++ b/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelPicUtil.java @@ -99,7 +99,12 @@ public class ExcelPicUtil { for (XSSFShape shape : shapes) { if(shape instanceof XSSFPicture){ pic = (XSSFPicture) shape; - ctMarker = pic.getPreferredSize().getFrom(); + try{ + ctMarker = pic.getPreferredSize().getFrom(); + }catch (Exception e){ + // 此处可能有空指针异常,跳过之 + continue; + } sheetIndexPicMap.put(StrUtil.format("{}_{}", ctMarker.getRow(), ctMarker.getCol()), pic.getPictureData()); } // 其他类似于图表等忽略,see: https://gitee.com/chinabugotech/hutool/issues/I38857