修改物资设备清单导入修改
This commit is contained in:
@ -140,29 +140,44 @@ public class ExcelReader {
|
||||
isFirstRow = false;
|
||||
continue;
|
||||
}
|
||||
if(hasValidData(row)){
|
||||
List<String> rowData = new ArrayList<>();
|
||||
// 读取A到E列(索引0到4)
|
||||
for (int cellIndex = 0; cellIndex < 6; cellIndex++) {
|
||||
Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
rowData.add(getCellValue(cell));
|
||||
}
|
||||
|
||||
List<String> rowData = new ArrayList<>();
|
||||
// 读取A到E列(索引0到4)
|
||||
for (int cellIndex = 0; cellIndex < 6; cellIndex++) {
|
||||
Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
rowData.add(getCellValue(cell));
|
||||
// 检查是否找到中文数字开头的行
|
||||
String aColumnValue = rowData.get(0).trim();
|
||||
if (aColumnValue.matches(CHINESE_NUMBERS_REGEX)) {
|
||||
foundChineseStart = true;
|
||||
}
|
||||
|
||||
// 只有找到中文数字开头的行之后,才开始收集数据
|
||||
if (foundChineseStart) {
|
||||
data.add(rowData);
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否找到中文数字开头的行
|
||||
String aColumnValue = rowData.get(0).trim();
|
||||
if (aColumnValue.matches(CHINESE_NUMBERS_REGEX)) {
|
||||
foundChineseStart = true;
|
||||
}
|
||||
|
||||
// 只有找到中文数字开头的行之后,才开始收集数据
|
||||
if (foundChineseStart) {
|
||||
data.add(rowData);
|
||||
}
|
||||
}
|
||||
|
||||
sheetData.setData(data);
|
||||
}
|
||||
|
||||
private static boolean hasValidData(Row row) {
|
||||
// 遍历行中的所有单元格
|
||||
for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) {
|
||||
Cell cell = row.getCell(cellIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
String cellValue = getCellValue(cell).trim();
|
||||
|
||||
// 只要有一个单元格有非空值,就认为是有效行
|
||||
if (!cellValue.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 根据数据构建树形结构
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user