|
|
|
@ -677,25 +677,39 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
case STRING: |
|
|
|
return cell.getStringCellValue(); |
|
|
|
case NUMERIC: |
|
|
|
if (DateUtil.isCellDateFormatted(cell)) { |
|
|
|
return new java.text.SimpleDateFormat("yyyy-MM-dd").format(cell.getDateCellValue()); |
|
|
|
} |
|
|
|
// 避免科学计数法 |
|
|
|
BigDecimal bd = new BigDecimal(String.valueOf(cell.getNumericCellValue())); |
|
|
|
return bd.stripTrailingZeros().toPlainString(); |
|
|
|
return formatNumericCellValue(cell); |
|
|
|
case BOOLEAN: |
|
|
|
return String.valueOf(cell.getBooleanCellValue()); |
|
|
|
case FORMULA: |
|
|
|
try { |
|
|
|
return String.valueOf(cell.getNumericCellValue()); |
|
|
|
CellType cachedType = cell.getCachedFormulaResultType(); |
|
|
|
if (cachedType == CellType.STRING) { |
|
|
|
return cell.getStringCellValue(); |
|
|
|
} |
|
|
|
if (cachedType == CellType.BOOLEAN) { |
|
|
|
return String.valueOf(cell.getBooleanCellValue()); |
|
|
|
} |
|
|
|
if (cachedType == CellType.NUMERIC) { |
|
|
|
return formatNumericCellValue(cell); |
|
|
|
} |
|
|
|
return ""; |
|
|
|
} catch (Exception e) { |
|
|
|
return cell.getStringCellValue(); |
|
|
|
return ""; |
|
|
|
} |
|
|
|
default: |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String formatNumericCellValue(Cell cell) { |
|
|
|
if (DateUtil.isCellDateFormatted(cell)) { |
|
|
|
return new java.text.SimpleDateFormat("yyyy-MM-dd").format(cell.getDateCellValue()); |
|
|
|
} |
|
|
|
// 避免科学计数法 |
|
|
|
BigDecimal bd = new BigDecimal(String.valueOf(cell.getNumericCellValue())); |
|
|
|
return bd.stripTrailingZeros().toPlainString(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* TX导入表头严格校验: |
|
|
|
* 1. 固定列必须全部存在 |
|
|
|
|