文档对比导出bug3.0

This commit is contained in:
CD
2022-10-08 16:34:37 +08:00
parent 05aa7f2c5c
commit cfed5d9e61
@@ -271,17 +271,18 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
row.createCell(2).setCellValue(itemLeft.getItemsName()); row.createCell(2).setCellValue(itemLeft.getItemsName());
String text = itemLeft.getItemsText(); String text = itemLeft.getItemsText();
text = text.replace("<p>", "").replace("</p>", "\r\n"); text = text.replace("<p>", "").replace("</p>", "\r\n");
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
addImgdata(text,request.getSession()); addImgdata(text,request.getSession());
String rowDataAndPath = (String) request.getSession().getAttribute("txtAndImg"); String rowDataAndPath = (String) request.getSession().getAttribute("txtAndImg");
leftSplit = rowDataAndPath.split("---"); leftSplit = rowDataAndPath.split("---");
if (leftSplit.length > 1) { if (leftSplit.length > 1) {
for (int j = 0; j < leftSplit.length; j++) { for (int j = 0; j < leftSplit.length; j++) {
if (ObjectUtils.isNotEmpty(leftSplit[j])) {
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
BufferedImage bufferImg = null; BufferedImage bufferImg = null;
if (j > 0) { if (j > 0) {
Row row2 = sheet.createRow(j + i); Row row2 = sheet.createRow(j + i);
if (leftSplit[j].contains("/upFiles")) { if (leftSplit[j].contains("/upFiles")) {
row2.setHeight((short) 5000); //设置行高 row2.setHeight((short) 3000); //设置行高
//先将图片下载到本地 //先将图片下载到本地
String fileLastName = leftSplit[j].substring(leftSplit[j].lastIndexOf("/") + 1); String fileLastName = leftSplit[j].substring(leftSplit[j].lastIndexOf("/") + 1);
if (CosBootUtil.doesObjectExist(leftSplit[j])) { if (CosBootUtil.doesObjectExist(leftSplit[j])) {
@@ -305,8 +306,8 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
row2.createCell(3).setCellValue(leftSplit[j]); row2.createCell(3).setCellValue(leftSplit[j]);
} }
} else { } else {
if (leftSplit[j].contains(".jpg") || leftSplit[j].contains(".png")) { if (leftSplit[j].contains("/upFiles")) {
row.setHeight((short) 5000); //设置行高 row.setHeight((short) 3000); //设置行高
//先将图片下载到本地 //先将图片下载到本地
String fileLastName = leftSplit[j].substring(leftSplit[j].lastIndexOf("/") + 1); String fileLastName = leftSplit[j].substring(leftSplit[j].lastIndexOf("/") + 1);
if (CosBootUtil.doesObjectExist(leftSplit[j])) { if (CosBootUtil.doesObjectExist(leftSplit[j])) {
@@ -331,6 +332,7 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
} }
} }
} }
}
sarFileCompareExcelMergeCell.setLeftStart(i); sarFileCompareExcelMergeCell.setLeftStart(i);
sarFileCompareExcelMergeCell.setLeftEnd(i + leftSplit.length - 1); sarFileCompareExcelMergeCell.setLeftEnd(i + leftSplit.length - 1);
sarFileCompareExcelMergeCell.setRightStart(0); sarFileCompareExcelMergeCell.setRightStart(0);
@@ -350,17 +352,18 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
row.createCell(6).setCellValue(itemRight.getItemsName()); row.createCell(6).setCellValue(itemRight.getItemsName());
String text = itemRight.getItemsText(); String text = itemRight.getItemsText();
text = text.replace("<p>", "").replace("</p>", "\r\n"); text = text.replace("<p>", "").replace("</p>", "\r\n");
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
addImgdata(text,request.getSession()); addImgdata(text,request.getSession());
String rowDataAndPath = (String) request.getSession().getAttribute("txtAndImg"); String rowDataAndPath = (String) request.getSession().getAttribute("txtAndImg");
rightSplit = rowDataAndPath.split("---"); rightSplit = rowDataAndPath.split("---");
if (rightSplit.length > 1) { if (rightSplit.length > 1) {
for (int j = 0; j < rightSplit.length; j++) { for (int j = 0; j < rightSplit.length; j++) {
if (ObjectUtils.isNotEmpty(rightSplit[j])) {
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
BufferedImage bufferImg = null; BufferedImage bufferImg = null;
if (j > 0) { if (j > 0) {
Row row2 = sheet.createRow(j + i); Row row2 = sheet.createRow(j + i);
if (rightSplit[j].contains("/upFiles")) { if (rightSplit[j].contains("/upFiles")) {
row2.setHeight((short) 5000); //设置行高 row2.setHeight((short) 3000); //设置行高
//先将图片下载到本地 //先将图片下载到本地
String fileLastName = rightSplit[j].substring(rightSplit[j].lastIndexOf("/") + 1); String fileLastName = rightSplit[j].substring(rightSplit[j].lastIndexOf("/") + 1);
if (CosBootUtil.doesObjectExist(rightSplit[j])) { if (CosBootUtil.doesObjectExist(rightSplit[j])) {
@@ -384,8 +387,8 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
row2.createCell(7).setCellValue(rightSplit[j]); row2.createCell(7).setCellValue(rightSplit[j]);
} }
} else { } else {
if (rightSplit[j].contains(".jpg") || rightSplit[j].contains(".png")) { if (rightSplit[j].contains("/upFiles")) {
row.setHeight((short) 5000); //设置行高 row.setHeight((short) 3000); //设置行高
//先将图片下载到本地 //先将图片下载到本地
String fileLastName = rightSplit[j].substring(rightSplit[j].lastIndexOf("/") + 1); String fileLastName = rightSplit[j].substring(rightSplit[j].lastIndexOf("/") + 1);
if (CosBootUtil.doesObjectExist(rightSplit[j])) { if (CosBootUtil.doesObjectExist(rightSplit[j])) {
@@ -401,7 +404,7 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
bufferImg = ImageIO.read(file); bufferImg = ImageIO.read(file);
ImageIO.write(bufferImg, "jpg", byteArrayOut); ImageIO.write(bufferImg, "jpg", byteArrayOut);
//anchor主要用于设置图片的属性 //anchor主要用于设置图片的属性
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 200, (short) 3, j + i, (short) 3, j + i); HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 200, (short) 7, j + i, (short) 7, j + i);
patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG));
} }
@@ -410,6 +413,7 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
} }
} }
} }
}
sarFileCompareExcelMergeCell.setRightStart(i); sarFileCompareExcelMergeCell.setRightStart(i);
sarFileCompareExcelMergeCell.setRightEnd(i + rightSplit.length - 1); sarFileCompareExcelMergeCell.setRightEnd(i + rightSplit.length - 1);
mergeCells.add(sarFileCompareExcelMergeCell); mergeCells.add(sarFileCompareExcelMergeCell);