|
@@ -17,11 +17,9 @@ import org.apache.commons.lang.math.NumberUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
-import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
|
-import org.apache.poi.ss.usermodel.VerticalAlignment;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
-import org.apache.poi.xssf.streaming.SXSSFRow;
|
|
|
-import org.apache.poi.xssf.streaming.SXSSFSheet;
|
|
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -135,7 +133,7 @@ public class ScoreExporter {
|
|
|
* @param index
|
|
|
* @return
|
|
|
*/
|
|
|
- public void drawExcelTeacher(int type, Map<String, ExportLevelResultDTO> map, SXSSFSheet sheet, CellStyle style, SXSSFRow row, AtomicInteger index) {
|
|
|
+ public void drawExcelTeacher(int type, Map<String, ExportLevelResultDTO> map, Sheet sheet, CellStyle style, Row row, AtomicInteger index) {
|
|
|
map.forEach((k, v) -> {
|
|
|
drawExcelFixedHead(sheet, style, row, new HeaderNode(String.valueOf(v.getTeacherName()) + TEACHER, 1, 1, index.get(), index.get()));
|
|
|
v.setFirstCol(index.get());
|
|
@@ -161,7 +159,7 @@ public class ScoreExporter {
|
|
|
* @param row
|
|
|
* @return
|
|
|
*/
|
|
|
- public SXSSFSheet drawExcelFixedHead(SXSSFSheet sheet, CellStyle style, SXSSFRow row, HeaderNode headerNode) {
|
|
|
+ public Sheet drawExcelFixedHead(Sheet sheet, CellStyle style, Row row, HeaderNode headerNode) {
|
|
|
Cell cell = row.createCell(headerNode.getFirstCol());
|
|
|
cell.setCellValue(headerNode.getName());
|
|
|
cell.setCellStyle(style);
|
|
@@ -179,33 +177,33 @@ public class ScoreExporter {
|
|
|
* @param row
|
|
|
* @param subjectMap
|
|
|
*/
|
|
|
- public SXSSFSheet drawExcelFixedHead(int type, SXSSFSheet sheet, CellStyle style, SXSSFRow row, Map<String, Map<String, ExportLevelResultDTO>> subjectMap) {
|
|
|
+ public Sheet drawExcelFixedHead(int type, Sheet sheet, CellStyle style, Row row, Map<String, Map<String, ExportLevelResultDTO>> subjectMap) {
|
|
|
//准考证号
|
|
|
Cell cell = row.createCell(0);
|
|
|
cell.setCellValue(EXAM_NUMBER);
|
|
|
cell.setCellStyle(style);
|
|
|
CellRangeAddress region1 = new CellRangeAddress(0, 1, (short) 0, (short) 0);
|
|
|
- sheet.addMergedRegionUnsafe(region1);
|
|
|
+ sheet.addMergedRegion(region1);
|
|
|
sheet.setColumnWidth(0, 15 * 256);
|
|
|
//姓名
|
|
|
Cell cell1 = row.createCell(1);
|
|
|
cell1.setCellValue(NAME);
|
|
|
cell1.setCellStyle(style);
|
|
|
CellRangeAddress region2 = new CellRangeAddress(0, 1, (short) 1, (short) 1);
|
|
|
- sheet.addMergedRegionUnsafe(region2);
|
|
|
+ sheet.addMergedRegion(region2);
|
|
|
//考区
|
|
|
Cell cell2 = row.createCell(2);
|
|
|
cell2.setCellValue(AREA_NAME);
|
|
|
cell2.setCellStyle(style);
|
|
|
CellRangeAddress region3 = new CellRangeAddress(0, 1, (short) 2, (short) 2);
|
|
|
- sheet.addMergedRegionUnsafe(region3);
|
|
|
+ sheet.addMergedRegion(region3);
|
|
|
sheet.setColumnWidth(2, 30 * 256);
|
|
|
//生源地
|
|
|
Cell cell3 = row.createCell(3);
|
|
|
cell3.setCellValue(SOURCE_NAME);
|
|
|
cell3.setCellStyle(style);
|
|
|
CellRangeAddress region4 = new CellRangeAddress(0, 1, (short) 3, (short) 3);
|
|
|
- sheet.addMergedRegionUnsafe(region4);
|
|
|
+ sheet.addMergedRegion(region4);
|
|
|
//色彩
|
|
|
int size = 0;
|
|
|
if (Objects.nonNull(subjectMap.get(Subject.SC.toString()))) {
|
|
@@ -222,7 +220,7 @@ public class ScoreExporter {
|
|
|
cell4.setCellStyle(style);
|
|
|
if (level != scSumCount) {
|
|
|
CellRangeAddress region5 = new CellRangeAddress(0, 0, (short) level, scSumCount);
|
|
|
- sheet.addMergedRegionUnsafe(region5);
|
|
|
+ sheet.addMergedRegion(region5);
|
|
|
}
|
|
|
LOGGER.info("level:{},scSumCount:{}", level, scSumCount);
|
|
|
|
|
@@ -243,7 +241,7 @@ public class ScoreExporter {
|
|
|
cell5.setCellStyle(style);
|
|
|
if (scSumCount != smSumCount) {
|
|
|
CellRangeAddress region6 = new CellRangeAddress(0, 0, (short) scSumCount, smSumCount);
|
|
|
- sheet.addMergedRegionUnsafe(region6);
|
|
|
+ sheet.addMergedRegion(region6);
|
|
|
}
|
|
|
LOGGER.info("scSumCount:{},smSumCount:{}", scSumCount, smSumCount);
|
|
|
//速写
|
|
@@ -263,7 +261,7 @@ public class ScoreExporter {
|
|
|
cell6.setCellStyle(style);
|
|
|
if (smSumCount != sxSumCount) {
|
|
|
CellRangeAddress region7 = new CellRangeAddress(0, 0, (short) smSumCount, sxSumCount);
|
|
|
- sheet.addMergedRegionUnsafe(region7);
|
|
|
+ sheet.addMergedRegion(region7);
|
|
|
}
|
|
|
LOGGER.info("smSumCount:{},sxSumCount:{}", smSumCount, sxSumCount);
|
|
|
return sheet;
|
|
@@ -298,17 +296,19 @@ public class ScoreExporter {
|
|
|
|
|
|
//创建excel
|
|
|
SXSSFWorkbook wb = new SXSSFWorkbook();
|
|
|
- SXSSFSheet sheet = wb.createSheet(LEVEL_FILE_NAME);
|
|
|
+ Sheet sheet = wb.createSheet(LEVEL_FILE_NAME);
|
|
|
CellStyle style = wb.createCellStyle();
|
|
|
- style.setAlignment(HorizontalAlignment.CENTER);// 左右居中
|
|
|
- style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
- SXSSFRow row = sheet.createRow(0);
|
|
|
+// style.setAlignment(HorizontalAlignment.CENTER);// 左右居中
|
|
|
+// style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 水平居中格式
|
|
|
+ style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); //垂直居中
|
|
|
+ Row row = sheet.createRow(0);
|
|
|
|
|
|
//绘制固定表头
|
|
|
sheet = drawExcelFixedHead(levelInterval, sheet, style, row, subjectMap);
|
|
|
|
|
|
//绘制动态表头
|
|
|
- SXSSFRow dynamicHeadRow = sheet.createRow(1);
|
|
|
+ Row dynamicHeadRow = sheet.createRow(1);
|
|
|
//SC表头
|
|
|
Map<String, ExportLevelResultDTO> scMap = subjectMap.get(Subject.SC.toString());
|
|
|
int size = 0;
|
|
@@ -329,13 +329,13 @@ public class ScoreExporter {
|
|
|
}
|
|
|
//加载excel数据
|
|
|
AtomicInteger cellIndex = new AtomicInteger(0);
|
|
|
- SXSSFSheet finalSheet = sheet;
|
|
|
+ Sheet finalSheet = sheet;
|
|
|
AtomicInteger i = new AtomicInteger(0);
|
|
|
AtomicInteger r = new AtomicInteger(2);
|
|
|
exportLevelResultDTOs.forEach((listk, listv) -> {
|
|
|
int firstRow = i.get() + r.get();
|
|
|
cellIndex.set(0);
|
|
|
- SXSSFRow hssfRow = finalSheet.createRow(firstRow);
|
|
|
+ Row hssfRow = finalSheet.createRow(firstRow);
|
|
|
drawExcelFixedHead(finalSheet, style, hssfRow, new HeaderNode(listv.getExamNumber(), firstRow, firstRow, cellIndex.get(), cellIndex.get()));
|
|
|
cellIndex.getAndIncrement();
|
|
|
drawExcelFixedHead(finalSheet, style, hssfRow, new HeaderNode(listv.getStudentName(), firstRow, firstRow, cellIndex.get(), cellIndex.get()));
|
|
@@ -412,17 +412,19 @@ public class ScoreExporter {
|
|
|
|
|
|
//创建excel
|
|
|
SXSSFWorkbook wb = new SXSSFWorkbook();
|
|
|
- SXSSFSheet sheet = wb.createSheet(SCORE_FILE_NAME);
|
|
|
+ Sheet sheet = wb.createSheet(SCORE_FILE_NAME);
|
|
|
CellStyle style = wb.createCellStyle();
|
|
|
- style.setAlignment(HorizontalAlignment.CENTER);// 左右居中
|
|
|
- style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
- SXSSFRow row = sheet.createRow(0);
|
|
|
+// style.setAlignment(HorizontalAlignment.CENTER);// 左右居中
|
|
|
+// style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 水平居中格式
|
|
|
+ style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); //垂直居中
|
|
|
+ Row row = sheet.createRow(0);
|
|
|
|
|
|
//绘制固定表头
|
|
|
sheet = drawExcelFixedHead(scoreInterval, sheet, style, row, subjectMap);
|
|
|
|
|
|
//绘制动态表头
|
|
|
- SXSSFRow dynamicHeadRow = sheet.createRow(1);
|
|
|
+ Row dynamicHeadRow = sheet.createRow(1);
|
|
|
//SC表头
|
|
|
Map<String, ExportLevelResultDTO> scMap = subjectMap.get(Subject.SC.toString());
|
|
|
int size = 0;
|
|
@@ -443,13 +445,13 @@ public class ScoreExporter {
|
|
|
}
|
|
|
//加载excel数据
|
|
|
AtomicInteger cellIndex = new AtomicInteger(0);
|
|
|
- SXSSFSheet finalSheet = sheet;
|
|
|
+ Sheet finalSheet = sheet;
|
|
|
AtomicInteger i = new AtomicInteger(0);
|
|
|
AtomicInteger r = new AtomicInteger(2);
|
|
|
exportLevelResultDTOs.forEach((listk, listv) -> {
|
|
|
int firstRow = i.get() + r.get();
|
|
|
cellIndex.set(0);
|
|
|
- SXSSFRow hssfRow = finalSheet.createRow(firstRow);
|
|
|
+ Row hssfRow = finalSheet.createRow(firstRow);
|
|
|
drawExcelFixedHead(finalSheet, style, hssfRow, new HeaderNode(listv.getExamNumber(), firstRow, firstRow, cellIndex.get(), cellIndex.get()));
|
|
|
cellIndex.getAndIncrement();
|
|
|
drawExcelFixedHead(finalSheet, style, hssfRow, new HeaderNode(listv.getStudentName(), firstRow, firstRow, cellIndex.get(), cellIndex.get()));
|