Looly 4 年 前
コミット
1f8bac4afa

+ 1 - 0
CHANGELOG.md

@@ -16,6 +16,7 @@
 * 【json   】     修复SQLEXception导致的栈溢出(issue#1399@Github)
 * 【extra  】     修复Ftp中异常参数没有传入问题(issue#1397@Github)
 * 【crypto 】     修复Sm2使用D构造空指针问题(issue#I37Z4C@Gitee)
+* 【poi    】     修复ExcelPicUtil中图表报错问题(issue#I38857@Gitee)
 
 -------------------------------------------------------------------------------------------------------------
 

+ 10 - 7
hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelPicUtil.java

@@ -25,14 +25,14 @@ import java.util.Map;
 
 /**
  * Excel图片工具类
- * 
+ *
  * @author looly
  * @since 4.0.7
  */
 public class ExcelPicUtil {
 	/**
 	 * 获取工作簿指定sheet中图片列表
-	 * 
+	 *
 	 * @param workbook 工作簿{@link Workbook}
 	 * @param sheetIndex sheet的索引
 	 * @return 图片映射,键格式:行_列,值:{@link PictureData}
@@ -55,7 +55,7 @@ public class ExcelPicUtil {
 	// -------------------------------------------------------------------------------------------------------------- Private method start
 	/**
 	 * 获取XLS工作簿指定sheet中图片列表
-	 * 
+	 *
 	 * @param workbook 工作簿{@link Workbook}
 	 * @param sheetIndex sheet的索引
 	 * @return 图片映射,键格式:行_列,值:{@link PictureData}
@@ -80,7 +80,7 @@ public class ExcelPicUtil {
 
 	/**
 	 * 获取XLSX工作簿指定sheet中图片列表
-	 * 
+	 *
 	 * @param workbook 工作簿{@link Workbook}
 	 * @param sheetIndex sheet的索引
 	 * @return 图片映射,键格式:行_列,值:{@link PictureData}
@@ -96,9 +96,12 @@ public class ExcelPicUtil {
 				XSSFPicture pic;
 				CTMarker ctMarker;
 				for (XSSFShape shape : shapes) {
-					pic = (XSSFPicture) shape;
-					ctMarker = pic.getPreferredSize().getFrom();
-					sheetIndexPicMap.put(StrUtil.format("{}_{}", ctMarker.getRow(), ctMarker.getCol()), pic.getPictureData());
+					if(shape instanceof XSSFPicture){
+						pic = (XSSFPicture) shape;
+						ctMarker = pic.getPreferredSize().getFrom();
+						sheetIndexPicMap.put(StrUtil.format("{}_{}", ctMarker.getRow(), ctMarker.getCol()), pic.getPictureData());
+					}
+					// 其他类似于图表等忽略,see: https://gitee.com/loolly/hutool/issues/I38857
 				}
 			}
 		}