Merge branch 'release/2.15.1.2407.01' into feature/240801-浮动薪资
This commit is contained in:
commit
94d068356b
|
|
@ -90,7 +90,7 @@ public class ExcelParseHelper {
|
|||
for (; rowIndex < rowCount; rowIndex++) {
|
||||
List<String> cellResult = new ArrayList<String>();
|
||||
for (int j = 0; j < cellCount; j++) {
|
||||
cellResult.add(ExcelSupport.getCellValue(sheet,null, rowIndex, j));
|
||||
cellResult.add(ExcelSupport.getCellValue(sheet, null, rowIndex, j));
|
||||
}
|
||||
result.add(cellResult);
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ public class ExcelParseHelper {
|
|||
for (; rowIndex < rowCount; rowIndex++) {
|
||||
List<String> cellResult = new ArrayList<String>();
|
||||
for (int j = 0; j < cellCount; j++) {
|
||||
cellResult.add(ExcelSupport.getCellValue(sheet,evaluator, rowIndex, j));
|
||||
cellResult.add(ExcelSupport.getCellValue(sheet, evaluator, rowIndex, j));
|
||||
}
|
||||
result.add(cellResult);
|
||||
}
|
||||
|
|
@ -137,7 +137,10 @@ public class ExcelParseHelper {
|
|||
* @return
|
||||
*/
|
||||
public static List<Map<String, Object>> parse2Map(InputStream file, int sheetIndex, int rowIndex) {
|
||||
Sheet sheet = ExcelSupport.parseFile(file, sheetIndex, EXCEL_TYPE_XLSX);
|
||||
Workbook workbook = ExcelSupport.parseFile(file, EXCEL_TYPE_XLSX);
|
||||
// 创建一个公式求值器对象
|
||||
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
|
||||
Sheet sheet = workbook.getSheetAt(sheetIndex);
|
||||
int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数
|
||||
int cellCount = sheet.getRow(PARSE_EXCEL_ROW_VALID_CELL_INDEX).getPhysicalNumberOfCells(); // 总列数
|
||||
|
||||
|
|
@ -148,7 +151,7 @@ public class ExcelParseHelper {
|
|||
Map<String, Object> cellResult = new HashMap<>();
|
||||
for (int j = 0; j < cellCount; j++) {
|
||||
String key = sheetHeader.get(j);
|
||||
cellResult.put(key, ExcelSupport.getCellValue(sheet,null, rowIndex, j));
|
||||
cellResult.put(key, ExcelSupport.getCellValue(sheet, evaluator, rowIndex, j));
|
||||
}
|
||||
result.add(cellResult);
|
||||
}
|
||||
|
|
@ -173,7 +176,28 @@ public class ExcelParseHelper {
|
|||
Map<String, Object> cellResult = new HashMap<>();
|
||||
for (int j = 0; j < cellCount; j++) {
|
||||
String key = sheetHeader.get(j);
|
||||
cellResult.put(key, ExcelSupport.getCellValue(sheet, null,rowIndex, j));
|
||||
cellResult.put(key, ExcelSupport.getCellValue(sheet, null, rowIndex, j));
|
||||
}
|
||||
result.add(cellResult);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<Map<String, Object>> parse2Map(Workbook workbook, int sheetIndex, int rowIndex) {
|
||||
// 创建一个公式求值器对象
|
||||
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
|
||||
Sheet sheet = workbook.getSheetAt(sheetIndex);
|
||||
int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数
|
||||
int cellCount = sheet.getRow(PARSE_EXCEL_ROW_VALID_CELL_INDEX).getPhysicalNumberOfCells(); // 总列数
|
||||
|
||||
List<String> sheetHeader = ExcelSupport.getSheetHeader(sheet, PARSE_EXCEL_ROW_VALID_CELL_INDEX);
|
||||
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
for (; rowIndex < rowCount; rowIndex++) {
|
||||
Map<String, Object> cellResult = new HashMap<>();
|
||||
for (int j = 0; j < cellCount; j++) {
|
||||
String key = sheetHeader.get(j);
|
||||
cellResult.put(key, ExcelSupport.getCellValue(sheet, evaluator, rowIndex, j));
|
||||
}
|
||||
result.add(cellResult);
|
||||
}
|
||||
|
|
@ -183,7 +207,7 @@ public class ExcelParseHelper {
|
|||
/**
|
||||
* 将sheet数据转为map
|
||||
*
|
||||
* @param rowIndex 从哪行开始解析
|
||||
* @param rowIndex 从哪行开始解析
|
||||
* @param headerRowIndex 抽取列数的参考行
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -198,7 +222,7 @@ public class ExcelParseHelper {
|
|||
Map<String, Object> cellResult = new HashMap<>();
|
||||
for (int j = 0; j < cellCount; j++) {
|
||||
String key = sheetHeader.get(j);
|
||||
cellResult.put(key, ExcelSupport.getCellValue(sheet, null,rowIndex, j));
|
||||
cellResult.put(key, ExcelSupport.getCellValue(sheet, null, rowIndex, j));
|
||||
}
|
||||
result.add(cellResult);
|
||||
}
|
||||
|
|
@ -219,7 +243,7 @@ public class ExcelParseHelper {
|
|||
for (; rowIndex < rowCount; rowIndex++) {
|
||||
List<String> cellResult = new ArrayList<String>();
|
||||
for (int j = 0; j < cellCount; j++) {
|
||||
cellResult.add(ExcelSupport.getCellValue(sheet,null, rowIndex, j));
|
||||
cellResult.add(ExcelSupport.getCellValue(sheet, null, rowIndex, j));
|
||||
}
|
||||
result.add(cellResult);
|
||||
}
|
||||
|
|
@ -228,7 +252,8 @@ public class ExcelParseHelper {
|
|||
|
||||
/**
|
||||
* 将sheet数据转为List
|
||||
* @param rowIndex 从哪行开始解析
|
||||
*
|
||||
* @param rowIndex 从哪行开始解析
|
||||
* @param headerRowIndex 抽取列数的参考行
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -240,7 +265,7 @@ public class ExcelParseHelper {
|
|||
for (; rowIndex < rowCount; rowIndex++) {
|
||||
List<String> cellResult = new ArrayList<String>();
|
||||
for (int j = 0; j < cellCount; j++) {
|
||||
cellResult.add(ExcelSupport.getCellValue(sheet,null, rowIndex, j));
|
||||
cellResult.add(ExcelSupport.getCellValue(sheet, null, rowIndex, j));
|
||||
}
|
||||
result.add(cellResult);
|
||||
}
|
||||
|
|
@ -249,11 +274,12 @@ public class ExcelParseHelper {
|
|||
|
||||
/**
|
||||
* 将sheet数据转为List
|
||||
* @param rowIndex 从哪行开始解析
|
||||
*
|
||||
* @param rowIndex 从哪行开始解析
|
||||
* @param headerRowIndex 抽取列数的参考行
|
||||
* @return
|
||||
*/
|
||||
public static List<List<String>> parse2List(Sheet sheet, FormulaEvaluator evaluator ,int rowIndex, int headerRowIndex) {
|
||||
public static List<List<String>> parse2List(Sheet sheet, FormulaEvaluator evaluator, int rowIndex, int headerRowIndex) {
|
||||
int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数
|
||||
int cellCount = sheet.getRow(headerRowIndex).getPhysicalNumberOfCells(); // 总列数
|
||||
|
||||
|
|
@ -261,7 +287,7 @@ public class ExcelParseHelper {
|
|||
for (; rowIndex < rowCount; rowIndex++) {
|
||||
List<String> cellResult = new ArrayList<String>();
|
||||
for (int j = 0; j < cellCount; j++) {
|
||||
cellResult.add(ExcelSupport.getCellValue(sheet,evaluator, rowIndex, j));
|
||||
cellResult.add(ExcelSupport.getCellValue(sheet, evaluator, rowIndex, j));
|
||||
}
|
||||
result.add(cellResult);
|
||||
}
|
||||
|
|
@ -343,8 +369,8 @@ public class ExcelParseHelper {
|
|||
// 创建一个公式求值器对象
|
||||
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
|
||||
Sheet sheet = workbook.getSheetAt(i);
|
||||
return ExcelPreviewDTO.builder()
|
||||
.headers(ExcelSupport.getSheetHeader(sheet, 0))
|
||||
.list(ExcelParseHelper.parse2List(sheet, evaluator ,1, 0)).build();
|
||||
return ExcelPreviewDTO.builder()
|
||||
.headers(ExcelSupport.getSheetHeader(sheet, 0))
|
||||
.list(ExcelParseHelper.parse2List(sheet, evaluator, 1, 0)).build();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue