main
黄海 2 years ago
parent 665fc3bfa3
commit 4705217d0c

@ -503,17 +503,24 @@ public class CollectModel {
} }
writeRecord.set(colName, value); writeRecord.set(colName, value);
} else { } else {
if (colType.equals("Integer")) if (colType.equals("Integer")) {
writeRecord.set(colName, (int) Double.parseDouble(PoiUtil.getValue(cell).toString())); if (StrKit.isBlank(PoiUtil.getValue(cell))) writeRecord.set(colName, null);
else if (colType.equals("String")) else
writeRecord.set(colName, PoiUtil.getValue(cell).toString()); writeRecord.set(colName, (int) Double.parseDouble(PoiUtil.getValue(cell).toString()));
else if (colType.equals("Double")) } else if (colType.equals("String")) {
writeRecord.set(colName, Double.parseDouble(PoiUtil.getValue(cell).toString())); if (StrKit.isBlank(PoiUtil.getValue(cell))) writeRecord.set(colName, null);
else if (colType.equals("Date")) { else writeRecord.set(colName, PoiUtil.getValue(cell).toString());
String dateString = PoiUtil.getValue(cell).toString(); } else if (colType.equals("Double")) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); if (StrKit.isBlank(PoiUtil.getValue(cell))) writeRecord.set(colName, null);
Date date = dateFormat.parse(dateString); else writeRecord.set(colName, Double.parseDouble(PoiUtil.getValue(cell).toString()));
writeRecord.set(colName, date); } else if (colType.equals("Date")) {
if (StrKit.isBlank(PoiUtil.getValue(cell))) writeRecord.set(colName, null);
else {
String dateString = PoiUtil.getValue(cell).toString();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = dateFormat.parse(dateString);
writeRecord.set(colName, date);
}
} }
} }
} }

@ -216,7 +216,6 @@ public class PoiUtil {
break; break;
case CellType.BOOLEAN: // Boolean case CellType.BOOLEAN: // Boolean
cellValue = cell.getBooleanCellValue() + ""; cellValue = cell.getBooleanCellValue() + "";
;
break; break;
case CellType.FORMULA: // 公式 case CellType.FORMULA: // 公式
cellValue = cell.getCellFormula(); cellValue = cell.getCellFormula();

Loading…
Cancel
Save