feat:excel图片问题
This commit is contained in:
1 parent
7d4b1e2339
commit
54b8037d7f
1 file changed
+14
-8
+14
-8
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.admin.utils.excel;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.EncryptedDocumentException;
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
import org.apache.poi.ooxml.POIXMLDocumentPart;
|
||||
@@ -20,6 +21,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@UtilityClass
|
||||
public class ExcelTool {
|
||||
|
||||
@@ -52,15 +54,19 @@ public class ExcelTool {
|
||||
*/
|
||||
public static Map<String, PictureData> getPictures(HSSFSheet sheet) throws IOException {
|
||||
Map<String, PictureData> map = new HashMap<String, PictureData>();
|
||||
List<HSSFShape> list = sheet.getDrawingPatriarch().getChildren();
|
||||
for (HSSFShape shape : list) {
|
||||
if (shape instanceof HSSFPicture) {
|
||||
HSSFPicture picture = (HSSFPicture) shape;
|
||||
HSSFClientAnchor cAnchor = picture.getClientAnchor();
|
||||
PictureData pdata = picture.getPictureData();
|
||||
String key = String.valueOf(cAnchor.getRow1());
|
||||
map.put(key, pdata);
|
||||
try {
|
||||
List<HSSFShape> list = sheet.getDrawingPatriarch().getChildren();
|
||||
for (HSSFShape shape : list) {
|
||||
if (shape instanceof HSSFPicture) {
|
||||
HSSFPicture picture = (HSSFPicture) shape;
|
||||
HSSFClientAnchor cAnchor = picture.getClientAnchor();
|
||||
PictureData pdata = picture.getPictureData();
|
||||
String key = String.valueOf(cAnchor.getRow1());
|
||||
map.put(key, pdata);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("getPictures 读取图片错误", e);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user