fix 条款导出空图片问题

This commit is contained in:
lijiarao
2024-08-15 16:20:44 +08:00
parent 483dcf3428
commit 8069b01891
2 changed files with 23 additions and 14 deletions
@@ -17,5 +17,7 @@ public class FileSplitValExportDto {
private String valContent;
private boolean hasImg;
private List<SarFileSplitItemsTableEO> tableEOList;
}
@@ -4046,7 +4046,6 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
String imgUUIndex = "img" + String.valueOf(imgIndex);
if (MyStringUtils.isNotEmpty(imgContent)){
lastOne.setValContent(imgUUIndex+".png");
valContent.add(lastOne);
FileSplitValImgExportDto fileSplitValImgExportDto = new FileSplitValImgExportDto();
fileSplitValImgExportDto.setImgName(imgUUIndex+".png");
String url = imgContent.substring(imgContent.lastIndexOf("=") + 1);
@@ -4055,7 +4054,11 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
if (StringUtils.isNotBlank(imgTranslation)){
String urlTranslation = imgTranslation.substring(imgTranslation.lastIndexOf("=") + 1);
fileSplitValImgExportDto.setImgPathTranslation(urlTranslation);
lastOne.setHasImg(true);
}else {
lastOne.setHasImg(false);
}
valContent.add(lastOne);
allImgList.add(fileSplitValImgExportDto);
imgIndex++;
@@ -4368,10 +4371,12 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
} else if ("IMG".equals(fileSplitValExportDto.getValType())) {
/* 连接跳转*/
CreationHelper createHelper = workbook.getCreationHelper();
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.FILE);
//Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.FILE);
String imgName = content;
hyperlink1.setAddress(imgName);
cell2.setHyperlink(hyperlink1);// 链接
//hyperlink1.setAddress(imgName);
//cell2.setHyperlink(hyperlink1);// 链接
row1.getCell(cellNum).setCellFormula("HYPERLINK(\"" + ".\\附件\\" + imgName + "\", \"" + "附件/" + imgName + "\")");
row1.getCell(cellNum).setCellValue("附件\\" + imgName);
row1.getCell(cellNum).setCellStyle(cellStyleLink);
}
cell2.setCellValue(content); // IllegalArgumentException异常excel单元格最大字符长度有限制
@@ -4401,17 +4406,19 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
row1.getCell(cellNum).setCellStyle(cellStyleLink);
} else if ("IMG".equals(fileSplitValExportDto.getValType())) {
/* 连接跳转*/
content = fileSplitValExportDto.getValContent();
content = content.substring(0,content.indexOf("."))+"translation.png";
CreationHelper createHelper = workbook.getCreationHelper();
// Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.FILE);
String imgName = content;
// hyperlink1.setAddress("附件\\" + imgName);
// cell2.setHyperlink(hyperlink1);// 链接
if (fileSplitValExportDto.isHasImg()) {
content = fileSplitValExportDto.getValContent();
content = content.substring(0,content.indexOf("."))+"translation.png";
CreationHelper createHelper = workbook.getCreationHelper();
// Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.FILE);
String imgName = content;
// hyperlink1.setAddress("附件\\" + imgName);
// cell2.setHyperlink(hyperlink1);// 链接
row1.getCell(cellNum).setCellFormula("HYPERLINK(\"" + ".\\附件\\" + imgName + "\", \"" + "附件/" + imgName + "\")");
row1.getCell(cellNum).setCellValue("附件\\" + imgName);
row1.getCell(cellNum).setCellStyle(cellStyleLink);
row1.getCell(cellNum).setCellFormula("HYPERLINK(\"" + ".\\附件\\" + imgName + "\", \"" + "附件/" + imgName + "\")");
row1.getCell(cellNum).setCellValue("附件\\" + imgName);
row1.getCell(cellNum).setCellStyle(cellStyleLink);
}
}
cell2.setCellValue(content); // IllegalArgumentException异常excel单元格最大字符长度有限制
}