add 文档拆分导出 增加表格译文
This commit is contained in:
@@ -18,4 +18,6 @@ public class FileSpiltValTableExportDto {
|
||||
private List<List<SarFileSplitItemsTableEO>> tableEOList;
|
||||
|
||||
private String tableHtCon;
|
||||
|
||||
private String tableHtConTranslation;
|
||||
}
|
||||
|
||||
@@ -13,4 +13,5 @@ public class FileSplitValImgExportDto {
|
||||
private String imgName;
|
||||
|
||||
private String imgPath;
|
||||
private String imgPathTranslation;
|
||||
}
|
||||
|
||||
+67
-11
@@ -3876,6 +3876,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
tableExportDto.setTableName("tableSheet" + tableName);
|
||||
// tableExportDto.setTableEOList(tableList);
|
||||
tableExportDto.setTableHtCon(itemsValEO.getItemContent());
|
||||
tableExportDto.setTableHtConTranslation(itemsValEO.getTranslation());
|
||||
allTableList.add(tableExportDto);
|
||||
tableIndex++;
|
||||
page.setTableIndex(tableIndex);
|
||||
@@ -3884,6 +3885,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
splitContext(valContent);
|
||||
|
||||
String imgContent = itemsValEO.getItemContent();
|
||||
String imgTranslation = itemsValEO.getTranslation();
|
||||
String imgUUIndex = "img" + String.valueOf(imgIndex);
|
||||
if (MyStringUtils.isNotEmpty(imgContent)){
|
||||
lastOne.setValContent(imgUUIndex+".png");
|
||||
@@ -3891,8 +3893,10 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
FileSplitValImgExportDto fileSplitValImgExportDto = new FileSplitValImgExportDto();
|
||||
fileSplitValImgExportDto.setImgName(imgUUIndex+".png");
|
||||
String url = imgContent.substring(imgContent.lastIndexOf("=") + 1);
|
||||
String urlTranslation = imgTranslation.substring(imgTranslation.lastIndexOf("=") + 1);
|
||||
|
||||
fileSplitValImgExportDto.setImgPath(url);
|
||||
fileSplitValImgExportDto.setImgPathTranslation(urlTranslation);
|
||||
|
||||
allImgList.add(fileSplitValImgExportDto);
|
||||
imgIndex++;
|
||||
@@ -4113,12 +4117,15 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
HSSFRow row1 = sheetItems.createRow(allRow);
|
||||
// 开始向单元格添加数据
|
||||
for(int cellNum = 0; cellNum < fieldList.size(); cellNum++){
|
||||
if (!"item_content".equals(fieldList.get(cellNum)) &&
|
||||
!"interpretation_articles".equals(fieldList.get(cellNum)) &&
|
||||
ObjectUtils.isNotEmpty(exportDto.get(fieldList.get(cellNum)))) {
|
||||
String fieldName = fieldList.get(cellNum);
|
||||
FileSplitValExportDto fileSplitValExportDto = valList.get(valRow);
|
||||
if (!"item_content".equals(fieldName) &&
|
||||
!"interpretation_articles".equals(fieldName) &&
|
||||
!"translation".equals(fieldName) &&
|
||||
ObjectUtils.isNotEmpty(exportDto.get(fieldName))) {
|
||||
// 处理文件
|
||||
if(fileList.contains(fieldList.get(cellNum))) {
|
||||
String connectId = (String) exportDto.get(fieldList.get(cellNum));
|
||||
if(fileList.contains(fieldName)) {
|
||||
String connectId = (String) exportDto.get(fieldName);
|
||||
List<OSSFile> ossFileList = ossFileService.getFileInfosByConnectId(connectId);
|
||||
List<String> fileNameList = new ArrayList<>();
|
||||
if (ossFileList != null && !ossFileList.isEmpty()) {
|
||||
@@ -4143,15 +4150,16 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
allRelevFileList.addAll(ossFileList);
|
||||
}
|
||||
} else {
|
||||
row1.createCell(cellNum).setCellValue(exportDto.get(fieldList.get(cellNum)).toString());
|
||||
row1.createCell(cellNum).setCellValue(exportDto.get(fieldName).toString());
|
||||
row1.getCell(cellNum).setCellStyle(cellStyle);
|
||||
}
|
||||
|
||||
} else if ("item_content".equals(fieldList.get(cellNum))) {
|
||||
}
|
||||
else if ("item_content".equals(fieldName)) {
|
||||
// 条款内容特殊处理
|
||||
HSSFCell cell2 = row1.createCell(cellNum);
|
||||
row1.getCell(cellNum).setCellStyle(cellStyle);
|
||||
String content = valList.get(valRow).getValContent();
|
||||
String content = fileSplitValExportDto.getValContent();
|
||||
if (StringUtils.isNotEmpty(content)) {
|
||||
content = content.replaceAll("null","");
|
||||
if (content.lastIndexOf("\n") > -1) {
|
||||
@@ -4159,7 +4167,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
}
|
||||
}
|
||||
|
||||
if("TABLE".equals(valList.get(valRow).getValType())){
|
||||
if("TABLE".equals(fileSplitValExportDto.getValType())){
|
||||
/* 连接跳转*/
|
||||
CreationHelper createHelper = workbook.getCreationHelper();
|
||||
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.DOCUMENT);
|
||||
@@ -4167,7 +4175,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
hyperlink1.setAddress(tableName);
|
||||
cell2.setHyperlink(hyperlink1);// 链接
|
||||
row1.getCell(cellNum).setCellStyle(cellStyleLink);
|
||||
} else if ("IMG".equals(valList.get(valRow).getValType())) {
|
||||
} else if ("IMG".equals(fileSplitValExportDto.getValType())) {
|
||||
/* 连接跳转*/
|
||||
CreationHelper createHelper = workbook.getCreationHelper();
|
||||
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.FILE);
|
||||
@@ -4177,7 +4185,41 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
row1.getCell(cellNum).setCellStyle(cellStyleLink);
|
||||
}
|
||||
cell2.setCellValue(content); // IllegalArgumentException异常,excel单元格最大字符长度有限制
|
||||
} else if ("interpretation_articles".equals(fieldList.get(cellNum))) {
|
||||
}
|
||||
else if ("translation".equals(fieldName)) {
|
||||
// 条款内容特殊处理
|
||||
HSSFCell cell2 = row1.createCell(cellNum);
|
||||
row1.getCell(cellNum).setCellStyle(cellStyle);
|
||||
String content = exportDto.get(fieldName).toString();
|
||||
if (StringUtils.isNotEmpty(content)) {
|
||||
content = content.replaceAll("null","");
|
||||
if (content.lastIndexOf("\n") > -1) {
|
||||
content = content.substring(0,content.lastIndexOf("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
if("TABLE".equals(fileSplitValExportDto.getValType())){
|
||||
/* 连接跳转*/
|
||||
content = fileSplitValExportDto.getValContent()+"translation";
|
||||
CreationHelper createHelper = workbook.getCreationHelper();
|
||||
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.DOCUMENT);
|
||||
String tableName = "#\'"+ content + "\'!A1";
|
||||
hyperlink1.setAddress(tableName);
|
||||
cell2.setHyperlink(hyperlink1);// 链接
|
||||
row1.getCell(cellNum).setCellStyle(cellStyleLink);
|
||||
} else if ("IMG".equals(fileSplitValExportDto.getValType())) {
|
||||
/* 连接跳转*/
|
||||
content = fileSplitValExportDto.getValContent()+"translation";
|
||||
CreationHelper createHelper = workbook.getCreationHelper();
|
||||
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.FILE);
|
||||
String imgName = content;
|
||||
hyperlink1.setAddress(imgName);
|
||||
cell2.setHyperlink(hyperlink1);// 链接
|
||||
row1.getCell(cellNum).setCellStyle(cellStyleLink);
|
||||
}
|
||||
cell2.setCellValue(content); // IllegalArgumentException异常,excel单元格最大字符长度有限制
|
||||
}
|
||||
else if ("interpretation_articles".equals(fieldName)) {
|
||||
// 条文解读特殊处理
|
||||
HSSFCell cell2 = row1.createCell(cellNum);
|
||||
row1.getCell(cellNum).setCellStyle(cellStyle);
|
||||
@@ -4261,6 +4303,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
// HSSFSheet sheetTable = workbook.createSheet(tableExportDto.getTableName());
|
||||
String tableName = tableExportDto.getTableName();
|
||||
String tableHtml = tableExportDto.getTableHtCon();
|
||||
String tableHtmlTranslation = tableExportDto.getTableHtConTranslation();
|
||||
|
||||
if (StringUtils.isNotEmpty(tableHtml) && tableHtml.indexOf("<tbody>") < 0) {
|
||||
if (tableHtml.indexOf("<thead>") < 0) {
|
||||
tableHtml = tableHtml.replaceFirst("<tr>","<tbody><tr>");
|
||||
@@ -4273,6 +4317,18 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
String cnt = "\n";
|
||||
tableHtml = tableHtml.replaceAll("<[\\s]*?br[^>]*?>|<[\\s]*?\\/[\\s]*?br[\\s]*?>", cnt);
|
||||
workbook = ConvertHtml2Excel.table2Excel(tableHtml,workbook,tableName);
|
||||
|
||||
if (StringUtils.isNotEmpty(tableHtmlTranslation) && tableHtmlTranslation.indexOf("<tbody>") < 0) {
|
||||
if (tableHtmlTranslation.indexOf("<thead>") < 0) {
|
||||
tableHtmlTranslation = tableHtmlTranslation.replaceFirst("<tr>","<tbody><tr>");
|
||||
tableHtmlTranslation = tableHtmlTranslation.replaceFirst("</table>","</tbody></table>");
|
||||
} else {
|
||||
tableHtmlTranslation = tableHtmlTranslation.replaceFirst("</thead>","</thead><tbody>");
|
||||
tableHtmlTranslation = tableHtmlTranslation.replaceFirst("</table>","</tbody></table>");
|
||||
}
|
||||
}
|
||||
tableHtmlTranslation = tableHtmlTranslation.replaceAll("<[\\s]*?br[^>]*?>|<[\\s]*?\\/[\\s]*?br[\\s]*?>", cnt);
|
||||
workbook = ConvertHtml2Excel.table2Excel(tableHtmlTranslation,workbook,tableName+"translation");
|
||||
// for (int r=0;r<rowtableList.size();r++) {
|
||||
// List<SarFileSplitItemsTableEO> colTableList = rowtableList.get(r);
|
||||
// HSSFRow tRow = sheetTable.createRow(colTableList.get(0).getRowNum()-1);
|
||||
|
||||
Reference in New Issue
Block a user