导出文档显示对应上下角标
This commit is contained in:
+55
-1
@@ -270,6 +270,41 @@ public class SarFileSplitItemsEOController extends BaseController<SarFileSplitIt
|
|||||||
content = content.substring(0,content.lastIndexOf("\n"));
|
content = content.substring(0,content.lastIndexOf("\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//处理上下角标
|
||||||
|
List<SplitFont> subList = new ArrayList<>();
|
||||||
|
List<SplitFont> supList = new ArrayList<>();
|
||||||
|
boolean handleCorner = false;
|
||||||
|
if (content.contains("<span class=sup>")) {
|
||||||
|
handleCornerMarkers(content, supList, "<span class=sup>","<span class=sub>");
|
||||||
|
}
|
||||||
|
if (content.contains("<span class=sub>")) {
|
||||||
|
handleCornerMarkers(content, subList, "<span class=sub>","<span class=sub>");
|
||||||
|
}
|
||||||
|
if (subList.size() > 0 || supList.size() > 0) {
|
||||||
|
content = content.replaceAll("<span class=sup>", "");
|
||||||
|
content = content.replaceAll("<span class=sub>", "");
|
||||||
|
content = content.replaceAll("</span>", "");
|
||||||
|
//设置角标font
|
||||||
|
HSSFFont fontSub = workbook.createFont();
|
||||||
|
fontSub.setTypeOffset(HSSFFont.SS_SUB);
|
||||||
|
HSSFFont fontSup = workbook.createFont();
|
||||||
|
fontSup.setTypeOffset(HSSFFont.SS_SUPER);
|
||||||
|
|
||||||
|
RichTextString richTextString = new HSSFRichTextString(content);
|
||||||
|
if (subList.size() > 0) {
|
||||||
|
for (SplitFont splitFont : subList) {
|
||||||
|
richTextString.applyFont(splitFont.getStartIndex(),splitFont.getEndIndex(),fontSub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (supList.size() > 0) {
|
||||||
|
for (SplitFont splitFont : supList) {
|
||||||
|
richTextString.applyFont(splitFont.getStartIndex(),splitFont.getEndIndex(),fontSup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cell2.setCellValue(richTextString);
|
||||||
|
handleCorner = true;
|
||||||
|
}
|
||||||
|
|
||||||
if("TABLE".equals(valList.get(valRow).getValType())){
|
if("TABLE".equals(valList.get(valRow).getValType())){
|
||||||
/* 连接跳转*/
|
/* 连接跳转*/
|
||||||
CreationHelper createHelper = workbook.getCreationHelper();
|
CreationHelper createHelper = workbook.getCreationHelper();
|
||||||
@@ -287,7 +322,9 @@ public class SarFileSplitItemsEOController extends BaseController<SarFileSplitIt
|
|||||||
cell2.setHyperlink(hyperlink1);// 链接
|
cell2.setHyperlink(hyperlink1);// 链接
|
||||||
row1.getCell(2).setCellStyle(cellStyleLink);
|
row1.getCell(2).setCellStyle(cellStyleLink);
|
||||||
}
|
}
|
||||||
cell2.setCellValue(content);
|
if (!handleCorner) {
|
||||||
|
cell2.setCellValue(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
row1.createCell(3).setCellValue(exportDto.getResponsibleUnitShow());
|
row1.createCell(3).setCellValue(exportDto.getResponsibleUnitShow());
|
||||||
@@ -414,6 +451,23 @@ public class SarFileSplitItemsEOController extends BaseController<SarFileSplitIt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleCornerMarkers(String content, List<SplitFont> splitFontList, String label,String remove) {
|
||||||
|
content = content.replaceAll(remove, "");
|
||||||
|
String[] split = content.split(label);
|
||||||
|
split[0] = split[0].replaceAll("</span>", "");
|
||||||
|
int index = split[0].length();
|
||||||
|
for (int i = 1; i < split.length; i++) {
|
||||||
|
SplitFont splitFont = new SplitFont();
|
||||||
|
String text = split[i];
|
||||||
|
String cornerLabel = text.substring(0, text.indexOf("</span>"));
|
||||||
|
splitFont.setStartIndex(index);
|
||||||
|
splitFont.setEndIndex(index + cornerLabel.length());
|
||||||
|
splitFontList.add(splitFont);
|
||||||
|
text = text.replaceAll("</span>", "");
|
||||||
|
index = index + text.length();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "|SarFileSplitItemsEO|导入")
|
@ApiOperation(value = "|SarFileSplitItemsEO|导入")
|
||||||
@PostMapping(value = "/importSplitItemsZip")
|
@PostMapping(value = "/importSplitItemsZip")
|
||||||
public ResponseMessage<SarFileSplitItemsEO> importSplitItemsZip(@RequestParam(value = "file", required = false) MultipartFile file,
|
public ResponseMessage<SarFileSplitItemsEO> importSplitItemsZip(@RequestParam(value = "file", required = false) MultipartFile file,
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.adc.da.slrs.standardSplit.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SplitFont {
|
||||||
|
Integer startIndex;
|
||||||
|
Integer endIndex;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user