|
@@ -26,6 +26,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
+import org.apache.poi.xssf.usermodel.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
@@ -176,11 +177,11 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
|
|
|
}
|
|
|
|
|
|
private void exportExcel(HttpServletResponse response, List<ProfessionalExportHead> professionalExportHeadList, List<List<String>> contentList, String professionalName) {
|
|
|
- HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
- HSSFSheet sheet = wb.createSheet(professionalName);
|
|
|
+ XSSFWorkbook wb = new XSSFWorkbook();
|
|
|
+ XSSFSheet sheet = wb.createSheet(professionalName);
|
|
|
|
|
|
// 表对样式
|
|
|
- HSSFCellStyle styleHead = wb.createCellStyle(); // 样式对象
|
|
|
+ XSSFCellStyle styleHead = wb.createCellStyle(); // 样式对象
|
|
|
styleHead.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直
|
|
|
styleHead.setAlignment(HorizontalAlignment.CENTER);// 水平
|
|
|
Font font = wb.createFont();
|
|
@@ -190,7 +191,7 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
|
|
|
styleHead.setFont(font);
|
|
|
|
|
|
//表格第一行(一级表头)
|
|
|
- HSSFRow row1 = sheet.createRow(0);
|
|
|
+ XSSFRow row1 = sheet.createRow(0);
|
|
|
// 计算一级表头合并单元格数量
|
|
|
Integer requirementCount = professionalExportHeadList.stream().filter(m -> m.getSubName() != null).map(m -> m.getSubName().size()).collect(Collectors.summingInt(Integer::intValue));
|
|
|
|
|
@@ -199,16 +200,16 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
|
|
|
}
|
|
|
|
|
|
sheet.addMergedRegion(new CellRangeAddress(0, 0, 1, requirementCount));
|
|
|
- HSSFCell cell0 = row1.createCell(0);
|
|
|
+ XSSFCell cell0 = row1.createCell(0);
|
|
|
cell0.setCellStyle(styleHead);
|
|
|
cell0.setCellValue("课程名称");
|
|
|
- HSSFCell cell1 = row1.createCell(1);
|
|
|
+ XSSFCell cell1 = row1.createCell(1);
|
|
|
cell1.setCellStyle(styleHead);
|
|
|
cell1.setCellValue("毕业要求");
|
|
|
|
|
|
//表格第二行(二级表头)
|
|
|
- HSSFRow row2 = sheet.createRow(1);
|
|
|
- HSSFCell cell2;
|
|
|
+ XSSFRow row2 = sheet.createRow(1);
|
|
|
+ XSSFCell cell2;
|
|
|
int num = 0;
|
|
|
for (int i = 0; i < professionalExportHeadList.size(); i++) {
|
|
|
ProfessionalExportHead professionalExportHead = professionalExportHeadList.get(i);
|
|
@@ -224,8 +225,8 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
|
|
|
}
|
|
|
|
|
|
//表格第三行(三级表头)
|
|
|
- HSSFRow row3 = sheet.createRow(2);
|
|
|
- HSSFCell cell3;
|
|
|
+ XSSFRow row3 = sheet.createRow(2);
|
|
|
+ XSSFCell cell3;
|
|
|
AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
for (ProfessionalExportHead professionalExportHead : professionalExportHeadList) {
|
|
|
for (String s : professionalExportHead.getSubName()) {
|
|
@@ -238,10 +239,10 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
|
|
|
sheet.addMergedRegion(new CellRangeAddress(0, 2, 0, 0));
|
|
|
|
|
|
AtomicInteger i = new AtomicInteger(3);
|
|
|
- HSSFRow row;
|
|
|
+ XSSFRow row;
|
|
|
for (List<String> list : contentList) {
|
|
|
row = sheet.createRow(i.getAndIncrement());
|
|
|
- HSSFCell cell;
|
|
|
+ XSSFCell cell;
|
|
|
for (int j = 0; j < list.size(); j++) {
|
|
|
cell = row.createCell(j);
|
|
|
cell.setCellValue(list.get(j));
|
|
@@ -250,7 +251,7 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
|
|
|
|
|
|
ServletOutputStream outputStream = null;
|
|
|
try {
|
|
|
- response.setHeader("Content-Disposition", "inline;filename=" + URLEncoder.encode(professionalName + "毕业要求支撑矩阵", SystemConstant.CHARSET_NAME) + SystemConstant.EXCEL_PREFIX);
|
|
|
+ response.setHeader("Content-Disposition", "filename=" + URLEncoder.encode(professionalName + "毕业要求支撑矩阵", SystemConstant.CHARSET_NAME) + SystemConstant.EXCEL_PREFIX);
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
|
outputStream = response.getOutputStream();
|
|
|
wb.write(outputStream);
|