文档对比图片bug2.0
This commit is contained in:
+96
-42
@@ -271,37 +271,64 @@ 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");
|
||||||
BufferedImage bufferImg = null;
|
|
||||||
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
|
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++) {
|
||||||
Row row2 = sheet.createRow(j + i);
|
BufferedImage bufferImg = null;
|
||||||
if (leftSplit[j].contains("/upFiles")) {
|
if (j > 0) {
|
||||||
row2.setHeight((short) 5000); //设置行高
|
Row row2 = sheet.createRow(j + i);
|
||||||
//先将图片下载到本地
|
if (leftSplit[j].contains("/upFiles")) {
|
||||||
String fileLastName = leftSplit[j].substring(leftSplit[j].lastIndexOf("/") + 1);
|
row2.setHeight((short) 5000); //设置行高
|
||||||
if (CosBootUtil.doesObjectExist(leftSplit[j])) {
|
//先将图片下载到本地
|
||||||
try (InputStream in = CosBootUtil.download(leftSplit[j])) {
|
String fileLastName = leftSplit[j].substring(leftSplit[j].lastIndexOf("/") + 1);
|
||||||
copyFile2(in, dir + File.separator + fileLastName);
|
if (CosBootUtil.doesObjectExist(leftSplit[j])) {
|
||||||
} catch (IOException e) {
|
try (InputStream in = CosBootUtil.download(leftSplit[j])) {
|
||||||
e.printStackTrace();
|
copyFile2(in, dir + File.separator + fileLastName);
|
||||||
log.error(e.getMessage(), e);
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
File file = new File(dir + File.separator + fileLastName);
|
||||||
File file = new File(dir + File.separator + fileLastName);
|
if (file.exists()) {
|
||||||
if (file.exists()) {
|
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) 3, j + i, (short) 3, j + i);
|
patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG));
|
||||||
patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG));
|
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
row2.createCell(3).setCellValue(leftSplit[j]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
row2.createCell(3).setCellValue(leftSplit[j]);
|
if (leftSplit[j].contains(".jpg") || leftSplit[j].contains(".png")) {
|
||||||
|
row.setHeight((short) 5000); //设置行高
|
||||||
|
//先将图片下载到本地
|
||||||
|
String fileLastName = leftSplit[j].substring(leftSplit[j].lastIndexOf("/") + 1);
|
||||||
|
if (CosBootUtil.doesObjectExist(leftSplit[j])) {
|
||||||
|
try (InputStream in = CosBootUtil.download(leftSplit[j])) {
|
||||||
|
copyFile2(in, dir + File.separator + fileLastName);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File file = new File(dir + File.separator + fileLastName);
|
||||||
|
if (file.exists()) {
|
||||||
|
bufferImg = ImageIO.read(file);
|
||||||
|
ImageIO.write(bufferImg, "jpg", byteArrayOut);
|
||||||
|
//anchor主要用于设置图片的属性
|
||||||
|
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 200, (short) 3, j + i, (short) 3, j + i);
|
||||||
|
patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG));
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
row.createCell(3).setCellValue(leftSplit[j]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sarFileCompareExcelMergeCell.setLeftStart(i);
|
sarFileCompareExcelMergeCell.setLeftStart(i);
|
||||||
@@ -323,37 +350,64 @@ 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");
|
||||||
BufferedImage bufferImg = null;
|
|
||||||
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
|
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++) {
|
||||||
Row row2 = sheet.createRow(j + i);
|
BufferedImage bufferImg = null;
|
||||||
if (rightSplit[j].contains("/upFiles")) {
|
if (j > 0) {
|
||||||
row2.setHeight((short) 5000); //设置行高
|
Row row2 = sheet.createRow(j + i);
|
||||||
//先将图片下载到本地
|
if (rightSplit[j].contains("/upFiles")) {
|
||||||
String fileLastName = rightSplit[j].substring(rightSplit[j].lastIndexOf("/") + 1);
|
row2.setHeight((short) 5000); //设置行高
|
||||||
if (CosBootUtil.doesObjectExist(rightSplit[j])) {
|
//先将图片下载到本地
|
||||||
try (InputStream in = CosBootUtil.download(rightSplit[j])) {
|
String fileLastName = rightSplit[j].substring(rightSplit[j].lastIndexOf("/") + 1);
|
||||||
copyFile2(in, dir + File.separator + fileLastName);
|
if (CosBootUtil.doesObjectExist(rightSplit[j])) {
|
||||||
} catch (IOException e) {
|
try (InputStream in = CosBootUtil.download(rightSplit[j])) {
|
||||||
e.printStackTrace();
|
copyFile2(in, dir + File.separator + fileLastName);
|
||||||
log.error(e.getMessage(), e);
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
File file = new File(dir + File.separator + fileLastName);
|
||||||
File file = new File(dir + File.separator + fileLastName);
|
if (file.exists()) {
|
||||||
if (file.exists()) {
|
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) 7, j + i, (short) 7, 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));
|
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
row2.createCell(7).setCellValue(rightSplit[j]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
row2.createCell(7).setCellValue(rightSplit[j]);
|
if (rightSplit[j].contains(".jpg") || rightSplit[j].contains(".png")) {
|
||||||
|
row.setHeight((short) 5000); //设置行高
|
||||||
|
//先将图片下载到本地
|
||||||
|
String fileLastName = rightSplit[j].substring(rightSplit[j].lastIndexOf("/") + 1);
|
||||||
|
if (CosBootUtil.doesObjectExist(rightSplit[j])) {
|
||||||
|
try (InputStream in = CosBootUtil.download(rightSplit[j])) {
|
||||||
|
copyFile2(in, dir + File.separator + fileLastName);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File file = new File(dir + File.separator + fileLastName);
|
||||||
|
if (file.exists()) {
|
||||||
|
bufferImg = ImageIO.read(file);
|
||||||
|
ImageIO.write(bufferImg, "jpg", byteArrayOut);
|
||||||
|
//anchor主要用于设置图片的属性
|
||||||
|
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 200, (short) 3, j + i, (short) 3, j + i);
|
||||||
|
patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG));
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
row.createCell(7).setCellValue(rightSplit[j]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sarFileCompareExcelMergeCell.setRightStart(i);
|
sarFileCompareExcelMergeCell.setRightStart(i);
|
||||||
|
|||||||
Reference in New Issue
Block a user