|
@@ -102,23 +102,24 @@ public class ExcelImportServer extends ImportBaseService {
|
|
|
*/
|
|
|
private String getKeyValue(Cell cell) {
|
|
|
Object obj = null;
|
|
|
- switch (cell.getCellType()) {
|
|
|
- case Cell.CELL_TYPE_STRING:
|
|
|
- obj = cell.getStringCellValue();
|
|
|
- break;
|
|
|
- case Cell.CELL_TYPE_BOOLEAN:
|
|
|
- obj = cell.getBooleanCellValue();
|
|
|
- break;
|
|
|
- case Cell.CELL_TYPE_NUMERIC:
|
|
|
- obj = cell.getNumericCellValue();
|
|
|
- break;
|
|
|
- case Cell.CELL_TYPE_FORMULA:
|
|
|
- obj = cell.getCellFormula();
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+ if(cell != null){
|
|
|
+ switch (cell.getCellType()) {
|
|
|
+ case Cell.CELL_TYPE_STRING:
|
|
|
+ obj = cell.getStringCellValue();
|
|
|
+ break;
|
|
|
+ case Cell.CELL_TYPE_BOOLEAN:
|
|
|
+ obj = cell.getBooleanCellValue();
|
|
|
+ break;
|
|
|
+ case Cell.CELL_TYPE_NUMERIC:
|
|
|
+ obj = cell.getNumericCellValue();
|
|
|
+ break;
|
|
|
+ case Cell.CELL_TYPE_FORMULA:
|
|
|
+ obj = cell.getCellFormula();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
return obj == null ? null : obj.toString().trim();
|
|
|
}
|
|
|
|
|
@@ -165,8 +166,11 @@ public class ExcelImportServer extends ImportBaseService {
|
|
|
String picId;
|
|
|
while (rows.hasNext() && (row == null || sheet.getLastRowNum() - row.getRowNum() > params.getLastOfInvalidRow())) {
|
|
|
row = rows.next();
|
|
|
+ int tempNum = params.getKeyIndex();
|
|
|
+ System.out.println("---------------111------------"+tempNum);
|
|
|
+ System.out.println("----------------3333-----------"+row.getCell(tempNum));
|
|
|
// 判断是集合元素还是不是集合元素,如果是就继续加入这个集合,不是就创建新的对象
|
|
|
- if ((row.getCell(params.getKeyIndex()) == null || StringUtils.isEmpty(getKeyValue(row.getCell(params.getKeyIndex())))) && object != null) {
|
|
|
+ if ((row.getCell(params.getKeyIndex()) == null && StringUtils.isNotEmpty(getKeyValue(row.getCell(params.getKeyIndex())))) && object != null) {
|
|
|
for (ExcelCollectionParams param : excelCollection) {
|
|
|
addListContinue(object, param, row, titlemap, targetId, pictures, params);
|
|
|
}
|
|
@@ -191,6 +195,7 @@ public class ExcelImportServer extends ImportBaseService {
|
|
|
}
|
|
|
collection.add(object);
|
|
|
} catch (ExcelImportException e) {
|
|
|
+ e.printStackTrace();
|
|
|
if (!e.getType().equals(ExcelImportEnum.VERIFY_ERROR)) {
|
|
|
throw new ExcelImportException(e.getType(), e);
|
|
|
}
|