修改文档对比-导出格式
This commit is contained in:
+1
-2
@@ -161,13 +161,12 @@ public class SarFileCompareItemCommentController extends JeroController<SarFileC
|
||||
@AutoLog(value = "文档对比信息条款评论表-导出结果")
|
||||
@ApiOperation(value = "文档对比信息条款评论表-导出结果", notes = "文档对比信息条款评论表-导出结果")
|
||||
@GetMapping(value = "/exportResXls")
|
||||
public Result<?> exportResXls(@RequestParam(name = "infoId", required = true) String infoId,
|
||||
public void exportResXls(@RequestParam(name = "infoId", required = true) String infoId,
|
||||
@RequestParam(name = "selectIds", required = true) String selectIds,
|
||||
@RequestParam(name = "includeComments", required = true) boolean includeComments,
|
||||
@RequestParam(name = "cut", required = true) String cut,
|
||||
HttpServletResponse response) {
|
||||
sarFileCompareItemCommentService.exportResXls(response, infoId, selectIds, includeComments, cut);
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+30
-14
@@ -188,7 +188,13 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
||||
response.setContentType("application/force-download");
|
||||
//创建工作表对象
|
||||
Sheet sheet = workbook.createSheet("对比结果");
|
||||
String sheetName = "对比结果";
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
sheetName = "对比结果";
|
||||
} else {
|
||||
sheetName = "Comparing results";
|
||||
}
|
||||
Sheet sheet = workbook.createSheet(sheetName);
|
||||
|
||||
// 创建头部
|
||||
String header = "";
|
||||
@@ -197,14 +203,17 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
|
||||
} else {
|
||||
header = "Number,Title,Content,Number,Title,Content,Comment";
|
||||
}
|
||||
int[] columnWidth = {5000, 5000, 10000, 5000, 5000, 10000, 10000};
|
||||
CellStyle cellStyle = workbook.createCellStyle();//初始化单元格格式对象
|
||||
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
cellStyle.setAlignment(HorizontalAlignment.LEFT);
|
||||
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
cellStyle.setWrapText(true);
|
||||
Row rowHeader = sheet.createRow(0);//开始创建标题行
|
||||
if (StringUtils.isNotBlank(header)) {
|
||||
String[] headerArr = header.split(",");
|
||||
for (int i = 0; i < headerArr.length; i++) {
|
||||
rowHeader.createCell(i).setCellValue(headerArr[i]);
|
||||
sheet.setColumnWidth(i, columnWidth[i]);
|
||||
}
|
||||
}
|
||||
int i = 1;
|
||||
@@ -219,18 +228,28 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
|
||||
String text = itemLeft.getItemsText();
|
||||
text = text.replace("<p>", "").replace("</p>", "\r\n");
|
||||
row.createCell(2).setCellValue(text);
|
||||
row.setRowStyle(cellStyle);
|
||||
}
|
||||
}
|
||||
String itemIdRight = itemComment.getItemsIdRight();
|
||||
SarFileCompareItem itemRight = sfcItemMap.get(itemIdRight);
|
||||
if (null != itemRight) {
|
||||
row.createCell(3).setCellValue(itemRight.getItemsNum());
|
||||
row.createCell(4).setCellValue(itemRight.getItemsName());
|
||||
String text = itemRight.getItemsText();
|
||||
text = text.replace("<p>", "").replace("</p>", "\r\n");
|
||||
row.createCell(5).setCellValue(text);
|
||||
if (!StringUtils.isEmpty(itemIdRight)) {
|
||||
SarFileCompareItem itemRight = sfcItemMap.get(itemIdRight);
|
||||
if (null != itemRight) {
|
||||
row.createCell(3).setCellValue(itemRight.getItemsNum());
|
||||
row.createCell(4).setCellValue(itemRight.getItemsName());
|
||||
String text = itemRight.getItemsText();
|
||||
text = text.replace("<p>", "").replace("</p>", "\r\n");
|
||||
row.createCell(5).setCellValue(text);
|
||||
row.setRowStyle(cellStyle);
|
||||
}
|
||||
}
|
||||
row.createCell(6).setCellValue(itemComment.getComment());
|
||||
for (int j = 0; j < 7; j++) {
|
||||
Cell cell = row.getCell(j);
|
||||
if (null != cell) {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (includeComments || StringUtils.isEmpty(selectIds)) {
|
||||
@@ -245,13 +264,10 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
|
||||
sheet.addMergedRegion(rangeAddress);
|
||||
SarFileCompareInfo compareInfo = sarFileCompareInfoServiceImpl.queryById(infoId);
|
||||
row.createCell(1).setCellValue(compareInfo.getComments());
|
||||
row.getCell(1).setCellStyle(cellStyle);
|
||||
}
|
||||
for (int j = 0; j < 7; j++) {
|
||||
sheet.autoSizeColumn(j, true);//设置列宽
|
||||
}
|
||||
|
||||
os = response.getOutputStream();
|
||||
// File file = new File("C://work/ee.xlsx");
|
||||
// os = new FileOutputStream(file);
|
||||
workbook.write(os);
|
||||
os.flush();
|
||||
} catch (IOException e) {
|
||||
|
||||
Reference in New Issue
Block a user