拆分对比-导出全文对比。
This commit is contained in:
+194
-88
@@ -534,6 +534,19 @@ public class SarFileCompareInfoServiceImpl extends ServiceImpl<SarFileCompareInf
|
||||
if (StringUtils.isNotEmpty(exportName)) {
|
||||
fileOriName = exportName;
|
||||
}
|
||||
|
||||
CellStyle cellStyle = workbook.createCellStyle();//初始化单元格格式对象
|
||||
cellStyle.setAlignment(HorizontalAlignment.LEFT);
|
||||
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
cellStyle.setWrapText(true);
|
||||
|
||||
//超链接样式
|
||||
CellStyle cellStyleLink =workbook.createCellStyle();
|
||||
HSSFFont font = ((HSSFWorkbook) workbook).createFont();
|
||||
font.setColor(HSSFColor.HSSFColorPredefined.LIGHT_BLUE.getIndex());
|
||||
cellStyleLink.setFont(font);
|
||||
cellStyleLink.setWrapText(true);
|
||||
|
||||
String[] headers = {"条款号","条款名称","条款内容","备注"};
|
||||
HSSFSheet sheetItemsLeft = workbook.createSheet("旧文档");
|
||||
// 左侧在excel表中添加表头
|
||||
@@ -580,116 +593,209 @@ public class SarFileCompareInfoServiceImpl extends ServiceImpl<SarFileCompareInf
|
||||
List<SarFileCompareItem> leftData = itemMap.get(CompareConst.POS_LEFT);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(leftData)) {
|
||||
//记录需要合并的单元格
|
||||
List<SarFileCompareExcelMergeCell> mergeCells = new ArrayList<>();
|
||||
|
||||
for (int rowNum = 0; rowNum < leftData.size(); rowNum++) {
|
||||
SarFileCompareExcelMergeCell sarFileCompareExcelMergeCell = new SarFileCompareExcelMergeCell();
|
||||
|
||||
SarFileCompareItem sarFileCompareItem = leftData.get(rowNum);
|
||||
|
||||
HSSFRow row1 = sheetItemsLeft.createRow(rowNum + 1);
|
||||
int i = 1;
|
||||
for (SarFileCompareItem sarFileCompareItem : leftData) {
|
||||
HSSFRow row1 = sheetItemsLeft.createRow(i);
|
||||
row1.createCell(0).setCellValue(sfcInfo.getSerialNumberLeft() + " " +sfcInfo.getTitleLeft());
|
||||
row1.createCell(1).setCellValue(sarFileCompareItem.getItemsNum());
|
||||
row1.getCell(1).setCellStyle(cellStyleBase);
|
||||
|
||||
String itemText = sarFileCompareItem.getItemsText();
|
||||
List<MarkTextVO> addList = new ArrayList<>();
|
||||
List<MarkTextVO> delList = new ArrayList<>();
|
||||
itemText = HtmlTextExcel.changeHtmlToExcel(sheetItemsLeft,workbook,request,itemText,addList,delList);
|
||||
HSSFRichTextString ts= new HSSFRichTextString(itemText);
|
||||
if (addList != null && !addList.isEmpty()) {
|
||||
for (MarkTextVO markTextVO : addList) {
|
||||
int stIndex = markTextVO.getStartIndex();
|
||||
int edIndex = markTextVO.getEndIndex();
|
||||
ts.applyFont(stIndex,edIndex,fontAdd);
|
||||
}
|
||||
}
|
||||
if (delList != null && !delList.isEmpty()) {
|
||||
for (MarkTextVO markTextVO : delList) {
|
||||
int stIndex = markTextVO.getStartIndex();
|
||||
int edIndex = markTextVO.getEndIndex();
|
||||
ts.applyFont(stIndex,edIndex,fontDel);
|
||||
}
|
||||
}
|
||||
row1.createCell(2).setCellValue(sarFileCompareItem.getItemsName());
|
||||
row1.createCell(3).setCellValue(ts);
|
||||
row1.getCell(3).setCellStyle(cellStyleBase);
|
||||
row1.createCell(4).setCellValue(sarFileCompareItem.getRemark());
|
||||
}
|
||||
String itemContent = sarFileCompareItem.getItemsText();
|
||||
|
||||
if (ObjectUtils.isNotEmpty(mergeCells)) {
|
||||
log.info("-------------- 开始处理需要合并的单元格 -----------------");
|
||||
Set<SarFileCompareExcelMergeCell> mergeCellSet = new HashSet<>(mergeCells);
|
||||
for (SarFileCompareExcelMergeCell mergeCell : mergeCellSet) {
|
||||
Integer leftCount = 0;
|
||||
if (ObjectUtils.isNotEmpty(mergeCell.getLeftEnd())&&ObjectUtils.isNotEmpty(mergeCell.getLeftStart())) {
|
||||
leftCount = mergeCell.getLeftEnd() - mergeCell.getLeftStart() + 1;
|
||||
}
|
||||
Integer rightCount = 0;
|
||||
if (ObjectUtils.isNotEmpty(mergeCell.getRightEnd())&&ObjectUtils.isNotEmpty(mergeCell.getRightStart())) {
|
||||
rightCount = mergeCell.getRightEnd() - mergeCell.getRightStart() + 1;
|
||||
}
|
||||
Integer start = leftCount - rightCount >= 0 ? mergeCell.getLeftStart() : mergeCell.getRightStart();
|
||||
log.info("-------------- 合并开始行数:" + start + " -----------------");
|
||||
Integer end = leftCount - rightCount >= 0 ? mergeCell.getLeftEnd() : mergeCell.getRightEnd();
|
||||
log.info("-------------- 合并结束行数: " + end + " -----------------");
|
||||
//合并
|
||||
if (ObjectUtils.isNotEmpty(start)&&ObjectUtils.isNotEmpty(end)) {
|
||||
CellRangeAddress region0 = new CellRangeAddress(start, end, 0, 0);
|
||||
sheetItemsLeft.addMergedRegion(region0);
|
||||
CellRangeAddress region1 = new CellRangeAddress(start, end, 1, 1);
|
||||
sheetItemsLeft.addMergedRegion(region1);
|
||||
CellRangeAddress region2 = new CellRangeAddress(start, end, 2, 2);
|
||||
sheetItemsLeft.addMergedRegion(region2);
|
||||
CellRangeAddress region4 = new CellRangeAddress(start, end, 4, 4);
|
||||
sheetItemsLeft.addMergedRegion(region4);
|
||||
CellRangeAddress region5 = new CellRangeAddress(start, end, 5, 5);
|
||||
sheetItemsLeft.addMergedRegion(region5);
|
||||
CellRangeAddress region6 = new CellRangeAddress(start, end, 6, 6);
|
||||
sheetItemsLeft.addMergedRegion(region6);
|
||||
CellRangeAddress region7 = new CellRangeAddress(start, end, 8, 8);
|
||||
sheetItemsLeft.addMergedRegion(region7);
|
||||
List<SarFileCompareExcelMergeCell> mergeCells = new ArrayList<>();
|
||||
String[] leftSplit = null;
|
||||
if (StringUtils.isNotEmpty(itemContent)) {
|
||||
String rowDataAndPath = HtmlTextExcel.getSplitContent(request, itemContent);
|
||||
HSSFPatriarch patriarch = (HSSFPatriarch) sheetItemsLeft.createDrawingPatriarch();
|
||||
|
||||
leftSplit = rowDataAndPath.split("---");
|
||||
|
||||
if (leftSplit.length > 1) {
|
||||
for (int j = 0; j < leftSplit.length; j++) {
|
||||
if (ObjectUtils.isNotEmpty(leftSplit[j])) {
|
||||
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
|
||||
if (j > 0) {
|
||||
Row row2 = sheetItemsLeft.getRow(j + i);
|
||||
if (ObjectUtils.isEmpty(row2)) {
|
||||
row2 = sheetItemsLeft.createRow(j + i);
|
||||
}
|
||||
log.info("-------------- 开始开始处理左侧图片、表格 -----------------");
|
||||
try {
|
||||
HtmlTextExcel.handleSpecificData(workbook, patriarch, cellStyleLink, byteArrayOut, row2, i, j, leftSplit[j], 2);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log.info("-------------- 左侧图片、表格 处理成功 -----------------");
|
||||
} else {
|
||||
log.info("-------------- 开始开始处理左侧图片、表格 -----------------");
|
||||
try {
|
||||
HtmlTextExcel.handleSpecificData(workbook, patriarch, cellStyleLink, byteArrayOut, row1, i, j, leftSplit[j], 2);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log.info("-------------- 左侧图片、表格 处理成功 -----------------");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SarFileCompareExcelMergeCell sarFileCompareExcelMergeCell = new SarFileCompareExcelMergeCell();
|
||||
sarFileCompareExcelMergeCell.setLeftStart(i);
|
||||
sarFileCompareExcelMergeCell.setLeftEnd(i + leftSplit.length - 1);
|
||||
sarFileCompareExcelMergeCell.setRightStart(0);
|
||||
sarFileCompareExcelMergeCell.setRightEnd(0);
|
||||
mergeCells.add(sarFileCompareExcelMergeCell);
|
||||
|
||||
} else {
|
||||
String text = HtmlTextExcel.changeHtmlToExcel(itemContent, null, null);
|
||||
row1.createCell(2).setCellValue(text);
|
||||
}
|
||||
|
||||
if (ObjectUtils.isNotEmpty(mergeCells)) {
|
||||
log.info("-------------- 开始处理需要合并的单元格 -----------------");
|
||||
Set<SarFileCompareExcelMergeCell> mergeCellSet = new HashSet<>(mergeCells);
|
||||
for (SarFileCompareExcelMergeCell mergeCell : mergeCellSet) {
|
||||
Integer leftCount = 0;
|
||||
if (ObjectUtils.isNotEmpty(mergeCell.getLeftEnd())&&ObjectUtils.isNotEmpty(mergeCell.getLeftStart())) {
|
||||
leftCount = mergeCell.getLeftEnd() - mergeCell.getLeftStart() + 1;
|
||||
}
|
||||
Integer rightCount = 0;
|
||||
if (ObjectUtils.isNotEmpty(mergeCell.getRightEnd())&&ObjectUtils.isNotEmpty(mergeCell.getRightStart())) {
|
||||
rightCount = mergeCell.getRightEnd() - mergeCell.getRightStart() + 1;
|
||||
}
|
||||
Integer start = leftCount - rightCount >= 0 ? mergeCell.getLeftStart() : mergeCell.getRightStart();
|
||||
log.info("-------------- 合并开始行数:" + start + " -----------------");
|
||||
Integer end = leftCount - rightCount >= 0 ? mergeCell.getLeftEnd() : mergeCell.getRightEnd();
|
||||
log.info("-------------- 合并结束行数: " + end + " -----------------");
|
||||
//合并
|
||||
if (ObjectUtils.isNotEmpty(start)&&ObjectUtils.isNotEmpty(end)) {
|
||||
CellRangeAddress region0 = new CellRangeAddress(start, end, 0, 0);
|
||||
sheetItemsLeft.addMergedRegion(region0);
|
||||
CellRangeAddress region1 = new CellRangeAddress(start, end, 1, 1);
|
||||
sheetItemsLeft.addMergedRegion(region1);
|
||||
CellRangeAddress region3 = new CellRangeAddress(start, end, 3, 3);
|
||||
sheetItemsLeft.addMergedRegion(region3);
|
||||
}
|
||||
|
||||
}
|
||||
log.info("-------------- 单元格合并成功 -----------------");
|
||||
}
|
||||
}
|
||||
log.info("-------------- 单元格合并成功 -----------------");
|
||||
|
||||
row1.createCell(3).setCellValue(sarFileCompareItem.getRemark());
|
||||
|
||||
row1.setRowStyle(cellStyle);
|
||||
for (int j = 0; j <= 3; j++) {
|
||||
Cell cell = row1.getCell(j);
|
||||
if (null != cell) {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
}
|
||||
int left_length = ObjectUtils.isEmpty(leftSplit) ? 1 : leftSplit.length;
|
||||
i = i + left_length;
|
||||
}
|
||||
}
|
||||
|
||||
List<SarFileCompareItem> rightData = itemMap.get(CompareConst.POS_RIGHT);
|
||||
if (CollectionUtils.isNotEmpty(rightData)) {
|
||||
for (int rowNum = 0; rowNum < rightData.size(); rowNum++) {
|
||||
SarFileCompareItem sarFileCompareItem = rightData.get(rowNum);
|
||||
|
||||
HSSFRow row1 = sheetItemsRight.createRow(rowNum + 1);
|
||||
int i = 1;
|
||||
for (SarFileCompareItem sarFileCompareItem : rightData) {
|
||||
HSSFRow row1 = sheetItemsRight.createRow(i);
|
||||
row1.createCell(0).setCellValue(sfcInfo.getSerialNumberRight() + " " +sfcInfo.getTitleRight());
|
||||
row1.createCell(1).setCellValue(sarFileCompareItem.getItemsNum());
|
||||
row1.getCell(1).setCellStyle(cellStyleBase);
|
||||
|
||||
String itemText = sarFileCompareItem.getItemsText();
|
||||
List<MarkTextVO> addList = new ArrayList<>();
|
||||
List<MarkTextVO> delList = new ArrayList<>();
|
||||
itemText = HtmlTextExcel.changeHtmlToExcel(sheetItemsRight,workbook,request,itemText,addList,delList);
|
||||
HSSFRichTextString ts= new HSSFRichTextString(itemText);
|
||||
if (addList != null && !addList.isEmpty()) {
|
||||
for (MarkTextVO markTextVO : addList) {
|
||||
int stIndex = markTextVO.getStartIndex();
|
||||
int edIndex = markTextVO.getEndIndex();
|
||||
ts.applyFont(stIndex,edIndex,fontAdd);
|
||||
String itemContent = sarFileCompareItem.getItemsText();
|
||||
List<SarFileCompareExcelMergeCell> mergeCells = new ArrayList<>();
|
||||
String[] rightSplit = null;
|
||||
if (StringUtils.isNotEmpty(itemContent)) {
|
||||
String rowDataAndPath = HtmlTextExcel.getSplitContent(request, itemContent);
|
||||
HSSFPatriarch patriarch = (HSSFPatriarch) sheetItemsRight.createDrawingPatriarch();
|
||||
|
||||
rightSplit = rowDataAndPath.split("---");
|
||||
|
||||
if (rightSplit.length > 1) {
|
||||
for (int j = 0; j < rightSplit.length; j++) {
|
||||
if (ObjectUtils.isNotEmpty(rightSplit[j])) {
|
||||
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
|
||||
if (j > 0) {
|
||||
Row row2 = sheetItemsRight.getRow(j + i);
|
||||
if (ObjectUtils.isEmpty(row2)) {
|
||||
row2 = sheetItemsRight.createRow(j + i);
|
||||
}
|
||||
log.info("-------------- 开始开始处理左侧图片、表格 -----------------");
|
||||
try {
|
||||
HtmlTextExcel.handleSpecificData(workbook, patriarch, cellStyleLink, byteArrayOut, row2, i, j, rightSplit[j], 2);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log.info("-------------- 左侧图片、表格 处理成功 -----------------");
|
||||
} else {
|
||||
log.info("-------------- 开始开始处理左侧图片、表格 -----------------");
|
||||
try {
|
||||
HtmlTextExcel.handleSpecificData(workbook, patriarch, cellStyleLink, byteArrayOut, row1, i, j, rightSplit[j], 2);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log.info("-------------- 左侧图片、表格 处理成功 -----------------");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SarFileCompareExcelMergeCell sarFileCompareExcelMergeCell = new SarFileCompareExcelMergeCell();
|
||||
sarFileCompareExcelMergeCell.setLeftStart(i);
|
||||
sarFileCompareExcelMergeCell.setLeftEnd(i + rightSplit.length - 1);
|
||||
sarFileCompareExcelMergeCell.setRightStart(0);
|
||||
sarFileCompareExcelMergeCell.setRightEnd(0);
|
||||
mergeCells.add(sarFileCompareExcelMergeCell);
|
||||
|
||||
} else {
|
||||
String text = HtmlTextExcel.changeHtmlToExcel(itemContent, null, null);
|
||||
row1.createCell(2).setCellValue(text);
|
||||
}
|
||||
|
||||
if (ObjectUtils.isNotEmpty(mergeCells)) {
|
||||
log.info("-------------- 开始处理需要合并的单元格 -----------------");
|
||||
Set<SarFileCompareExcelMergeCell> mergeCellSet = new HashSet<>(mergeCells);
|
||||
for (SarFileCompareExcelMergeCell mergeCell : mergeCellSet) {
|
||||
Integer leftCount = 0;
|
||||
if (ObjectUtils.isNotEmpty(mergeCell.getLeftEnd())&&ObjectUtils.isNotEmpty(mergeCell.getLeftStart())) {
|
||||
leftCount = mergeCell.getLeftEnd() - mergeCell.getLeftStart() + 1;
|
||||
}
|
||||
Integer rightCount = 0;
|
||||
if (ObjectUtils.isNotEmpty(mergeCell.getRightEnd())&&ObjectUtils.isNotEmpty(mergeCell.getRightStart())) {
|
||||
rightCount = mergeCell.getRightEnd() - mergeCell.getRightStart() + 1;
|
||||
}
|
||||
Integer start = leftCount - rightCount >= 0 ? mergeCell.getLeftStart() : mergeCell.getRightStart();
|
||||
log.info("-------------- 合并开始行数:" + start + " -----------------");
|
||||
Integer end = leftCount - rightCount >= 0 ? mergeCell.getLeftEnd() : mergeCell.getRightEnd();
|
||||
log.info("-------------- 合并结束行数: " + end + " -----------------");
|
||||
//合并
|
||||
if (ObjectUtils.isNotEmpty(start)&&ObjectUtils.isNotEmpty(end)) {
|
||||
CellRangeAddress region0 = new CellRangeAddress(start, end, 0, 0);
|
||||
sheetItemsRight.addMergedRegion(region0);
|
||||
CellRangeAddress region1 = new CellRangeAddress(start, end, 1, 1);
|
||||
sheetItemsRight.addMergedRegion(region1);
|
||||
CellRangeAddress region3 = new CellRangeAddress(start, end, 3, 3);
|
||||
sheetItemsRight.addMergedRegion(region3);
|
||||
}
|
||||
|
||||
}
|
||||
log.info("-------------- 单元格合并成功 -----------------");
|
||||
}
|
||||
}
|
||||
if (delList != null && !delList.isEmpty()) {
|
||||
for (MarkTextVO markTextVO : delList) {
|
||||
int stIndex = markTextVO.getStartIndex();
|
||||
int edIndex = markTextVO.getEndIndex();
|
||||
ts.applyFont(stIndex,edIndex,fontDel);
|
||||
|
||||
row1.createCell(3).setCellValue(sarFileCompareItem.getRemark());
|
||||
|
||||
row1.setRowStyle(cellStyle);
|
||||
for (int j = 0; j <= 3; j++) {
|
||||
Cell cell = row1.getCell(j);
|
||||
if (null != cell) {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
}
|
||||
row1.createCell(2).setCellValue(sarFileCompareItem.getItemsName());
|
||||
row1.createCell(3).setCellValue(ts);
|
||||
row1.getCell(3).setCellStyle(cellStyleBase);
|
||||
row1.createCell(4).setCellValue(sarFileCompareItem.getRemark());
|
||||
int left_length = ObjectUtils.isEmpty(rightSplit) ? 1 : rightSplit.length;
|
||||
i = i + left_length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -92,6 +92,7 @@ public class SarItemsCompareHisEOServiceImpl extends ServiceImpl<SarItemsCompare
|
||||
String fileName = fileOriName + ".xlsx";
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
exportParams.setSheetName("条款对比信息");
|
||||
workbook = ExcelExportUtil.exportExcel(exportParams, SarItemsCompareHisEO.class, exportDataList);
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=\"" + ReadExcel.encodeFileName(fileName, request) +"\"");
|
||||
|
||||
+7
-59
@@ -10,6 +10,7 @@ import org.apache.poi.common.usermodel.HyperlinkType;
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
import org.apache.poi.hssf.util.HSSFColor;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -20,21 +21,13 @@ import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
public class HtmlTextExcel {
|
||||
|
||||
public static String changeHtmlToExcel (HSSFSheet sheetItemsLeft,HSSFWorkbook wb, HttpServletRequest request, String itemContent, List<MarkTextVO> addList, List<MarkTextVO> delList) {
|
||||
//超链接样式
|
||||
Workbook workbook = new HSSFWorkbook();
|
||||
CellStyle cellStyleLink =workbook.createCellStyle();
|
||||
HSSFFont font = ((HSSFWorkbook) workbook).createFont();
|
||||
font.setColor(HSSFColor.HSSFColorPredefined.LIGHT_BLUE.getIndex());
|
||||
cellStyleLink.setFont(font);
|
||||
cellStyleLink.setWrapText(true);
|
||||
public static String changeHtmlToExcel (String itemContent, List<MarkTextVO> addList, List<MarkTextVO> delList) {
|
||||
if (StringUtils.isNotEmpty(itemContent)) {
|
||||
itemContent = itemContent.replaceAll("<div>","");
|
||||
itemContent = itemContent.replaceAll("<div class=\"compareBackgroundColor\">","");
|
||||
@@ -85,51 +78,6 @@ public class HtmlTextExcel {
|
||||
itemContent = itemContent.replaceAll("</span>","");
|
||||
itemContent = itemContent.replaceAll("<span class=\"delClass\">","");
|
||||
itemContent = itemContent.replaceAll("</span>","");
|
||||
String rowDataAndPath = getSplitContent(request, itemContent);
|
||||
// String dir = filePath + File.separator + UUID.randomUUID().toString().replace("-", "");
|
||||
String sheetName = "对比结果";
|
||||
Sheet sheet = workbook.createSheet(sheetName);
|
||||
HSSFPatriarch patriarch = (HSSFPatriarch) sheet.createDrawingPatriarch();
|
||||
String[] leftSplit = null;
|
||||
leftSplit = rowDataAndPath.split("---");
|
||||
int i = 1;
|
||||
Row row = sheet.createRow(i);
|
||||
if (leftSplit.length > 1) {
|
||||
for (int j = 0; j < leftSplit.length; j++) {
|
||||
if (ObjectUtils.isNotEmpty(leftSplit[j])) {
|
||||
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
|
||||
if (j > 0) {
|
||||
Row row2 = sheet.getRow(j );
|
||||
if (ObjectUtils.isEmpty(row2)) {
|
||||
row2 = sheet.createRow(j);
|
||||
}
|
||||
log.info("-------------- 开始开始处理左侧图片、表格 -----------------");
|
||||
try {
|
||||
handleSpecificData(wb, patriarch, cellStyleLink, byteArrayOut, row2, i, j, leftSplit[j], 3);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log.info("-------------- 左侧图片、表格 处理成功 -----------------");
|
||||
} else {
|
||||
log.info("-------------- 开始开始处理左侧图片、表格 -----------------");
|
||||
try {
|
||||
handleSpecificData(wb, patriarch, cellStyleLink, byteArrayOut, row, i, j, leftSplit[j], 3);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log.info("-------------- 左侧图片、表格 处理成功 -----------------");
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SarFileCompareExcelMergeCell> mergeCells = new ArrayList<>();
|
||||
SarFileCompareExcelMergeCell sarFileCompareExcelMergeCell = new SarFileCompareExcelMergeCell();
|
||||
sarFileCompareExcelMergeCell.setLeftStart(i);
|
||||
sarFileCompareExcelMergeCell.setLeftEnd(i + leftSplit.length - 1);
|
||||
sarFileCompareExcelMergeCell.setRightStart(0);
|
||||
sarFileCompareExcelMergeCell.setRightEnd(0);
|
||||
mergeCells.add(sarFileCompareExcelMergeCell);
|
||||
}
|
||||
|
||||
}
|
||||
return itemContent;
|
||||
}
|
||||
@@ -147,7 +95,7 @@ public class HtmlTextExcel {
|
||||
* @param cellNum
|
||||
* @throws IOException
|
||||
*/
|
||||
private static void handleSpecificData(HSSFWorkbook workbook, HSSFPatriarch patriarch, CellStyle cellStyleLink, ByteArrayOutputStream byteArrayOut, Row row, int i, int j, String text, int cellNum) throws IOException {
|
||||
public static void handleSpecificData(HSSFWorkbook workbook, HSSFPatriarch patriarch, CellStyle cellStyleLink, ByteArrayOutputStream byteArrayOut, Row row, int i, int j, String text, int cellNum) throws IOException {
|
||||
if (text.contains("/upFiles")) {
|
||||
String dir = "dcjd";
|
||||
row.setHeight((short) 3000); //设置行高
|
||||
@@ -261,7 +209,7 @@ public class HtmlTextExcel {
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
private static String getSplitContent(HttpServletRequest request, String text) {
|
||||
public static String getSplitContent(HttpServletRequest request, String text) {
|
||||
text = text.replace("<p>", "").replace("</p>", "\r\n");
|
||||
//分割图片
|
||||
log.info("-------------------------开始分割文字与图片---------------------------");
|
||||
@@ -281,7 +229,7 @@ public class HtmlTextExcel {
|
||||
* @param textAndImg
|
||||
* @param session
|
||||
*/
|
||||
private static void splitTable(String textAndImg,HttpSession session) {
|
||||
public static void splitTable(String textAndImg, HttpSession session) {
|
||||
if (textAndImg.contains("<replaceTable")) {
|
||||
String left = textAndImg.substring(0, textAndImg.indexOf("<replaceTable"));
|
||||
String right = textAndImg.substring(textAndImg.indexOf("/replaceTable>") + 14);
|
||||
@@ -300,7 +248,7 @@ public class HtmlTextExcel {
|
||||
* @param session
|
||||
* @return
|
||||
*/
|
||||
private static void splitImg(String text, HttpSession session) {
|
||||
public static void splitImg(String text, HttpSession session) {
|
||||
if (text.contains("<img")) {
|
||||
String txtLeft = text.substring(0, text.indexOf("<img"));
|
||||
String txtRight = text.substring(text.indexOf("g\">") + 3);
|
||||
|
||||
Reference in New Issue
Block a user