修改拆分表格包公式
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package com.jero.modules.split.entity;
|
||||||
|
|
||||||
|
public class MathNumber {
|
||||||
|
int number;
|
||||||
|
|
||||||
|
public MathNumber() {
|
||||||
|
this.number = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumber() {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumber(int number) {
|
||||||
|
this.number = number;
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
-5
@@ -237,7 +237,8 @@ public class FileSpiltService {
|
|||||||
}
|
}
|
||||||
log.info("下载文档结束=========================================================");
|
log.info("下载文档结束=========================================================");
|
||||||
}
|
}
|
||||||
|
//记录公式自动编号
|
||||||
|
MathNumber mathNumber = new MathNumber();
|
||||||
try (InputStream is = splitFileIs;InputStream is1 = splitFileIs1) {
|
try (InputStream is = splitFileIs;InputStream is1 = splitFileIs1) {
|
||||||
ZipSecureFile.setMinInflateRatio(-1.0d);
|
ZipSecureFile.setMinInflateRatio(-1.0d);
|
||||||
XWPFDocument doc = new XWPFDocument(is);
|
XWPFDocument doc = new XWPFDocument(is);
|
||||||
@@ -485,7 +486,7 @@ public class FileSpiltService {
|
|||||||
}
|
}
|
||||||
else if (element instanceof XWPFTable) {
|
else if (element instanceof XWPFTable) {
|
||||||
if (!messageList.isEmpty()) {
|
if (!messageList.isEmpty()) {
|
||||||
addItermsConditionsOfTable(messageList.get(messageList.size() - 1), itemValList, (XWPFTable) element);
|
addItermsConditionsOfTable(messageList.get(messageList.size() - 1), itemValList, (XWPFTable) element,mathNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1085,10 +1086,10 @@ public class FileSpiltService {
|
|||||||
itemsValList.add(getSplitItemsValObject(message.getId(), SplitFilePragraTypeEnum.MATH.getValue(), p, message.getItemsCondi().size(), null));
|
itemsValList.add(getSplitItemsValObject(message.getId(), SplitFilePragraTypeEnum.MATH.getValue(), p, message.getItemsCondi().size(), null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItermsConditionsOfTable(SarFileSplitItemsEO message, List<SarFileSplitItemsValEO> itemsValList, XWPFTable table) throws IOException {
|
public void addItermsConditionsOfTable(SarFileSplitItemsEO message, List<SarFileSplitItemsValEO> itemsValList, XWPFTable table,MathNumber mathNumber) throws IOException {
|
||||||
StringBuilder tabaleStringNew = new StringBuilder("");
|
StringBuilder tabaleStringNew = new StringBuilder("");
|
||||||
//将表格转为html字符串
|
//将表格转为html字符串
|
||||||
String tableStr = readTable(table);
|
String tableStr = readTable(table,mathNumber);
|
||||||
tabaleStringNew.append(tableStr);
|
tabaleStringNew.append(tableStr);
|
||||||
message.getItemsCondi().add(table.getText());
|
message.getItemsCondi().add(table.getText());
|
||||||
message.setItemContent(message.getItemContent() + tabaleStringNew);
|
message.setItemContent(message.getItemContent() + tabaleStringNew);
|
||||||
@@ -1096,7 +1097,8 @@ public class FileSpiltService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String readTable(XWPFTable table) {
|
public String readTable(XWPFTable table,MathNumber mathNumber) {
|
||||||
|
boolean isMathNumber = false;
|
||||||
ReadWordTable readWordTable = new ReadWordTable();
|
ReadWordTable readWordTable = new ReadWordTable();
|
||||||
// 表格行数
|
// 表格行数
|
||||||
int tableRowsSize = table.getRows().size();
|
int tableRowsSize = table.getRows().size();
|
||||||
@@ -1136,6 +1138,13 @@ public class FileSpiltService {
|
|||||||
tableToHtmlStr.append(">");
|
tableToHtmlStr.append(">");
|
||||||
}
|
}
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
if(isMathNumber && j == 1){
|
||||||
|
stringBuilder.append("..................("+mathNumber.getNumber()+")");
|
||||||
|
tableToHtmlStr.append(stringBuilder).append("</td>");
|
||||||
|
mathNumber.setNumber(mathNumber.getNumber() + 1);
|
||||||
|
isMathNumber = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
List<XWPFParagraph> paragraphs = tableCell.getParagraphs();
|
List<XWPFParagraph> paragraphs = tableCell.getParagraphs();
|
||||||
for (XWPFParagraph paragraph : paragraphs) {
|
for (XWPFParagraph paragraph : paragraphs) {
|
||||||
List<String> imageBundleList = readImageInParagraph(paragraph);
|
List<String> imageBundleList = readImageInParagraph(paragraph);
|
||||||
@@ -1185,6 +1194,7 @@ public class FileSpiltService {
|
|||||||
|
|
||||||
String imgConVal = "<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\"" + path + "\">";
|
String imgConVal = "<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\"" + path + "\">";
|
||||||
stringBuilder.append(imgConVal);
|
stringBuilder.append(imgConVal);
|
||||||
|
isMathNumber = true;
|
||||||
}
|
}
|
||||||
} else if (child instanceof CTOMathPara) {
|
} else if (child instanceof CTOMathPara) {
|
||||||
CTOMathPara ctoMathPara = (CTOMathPara) child;
|
CTOMathPara ctoMathPara = (CTOMathPara) child;
|
||||||
@@ -1229,6 +1239,7 @@ public class FileSpiltService {
|
|||||||
|
|
||||||
String imgConVal = "<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\"" + path + "\">";
|
String imgConVal = "<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\"" + path + "\">";
|
||||||
stringBuilder.append(imgConVal);
|
stringBuilder.append(imgConVal);
|
||||||
|
isMathNumber = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user