|
|
@ -5,9 +5,9 @@ import cn.hutool.core.util.StrUtil; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
import lombok.Data; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.poi.POIXMLDocumentPart; |
|
|
|
import org.apache.poi.common.usermodel.HyperlinkType; |
|
|
|
import org.apache.poi.hssf.usermodel.*; |
|
|
|
import org.apache.poi.ooxml.POIXMLDocumentPart; |
|
|
|
import org.apache.poi.ss.usermodel.DateUtil; |
|
|
|
import org.apache.poi.ss.usermodel.*; |
|
|
|
import org.apache.poi.ss.util.CellRangeAddress; |
|
|
@ -350,7 +350,7 @@ public class PoiUtil { |
|
|
|
String cellValue = null; |
|
|
|
// 判断excel单元格内容的格式,并对其进行转换,以便插入数据库
|
|
|
|
switch (cell.getCellType()) { |
|
|
|
case 0://number类型
|
|
|
|
case NUMERIC://number类型
|
|
|
|
//时间类型也被认为是number类型,所以在读取数据时需进行判断
|
|
|
|
if (DateUtil.isCellDateFormatted(cell)) { |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); |
|
|
@ -359,10 +359,10 @@ public class PoiUtil { |
|
|
|
cellValue = new DecimalFormat("0").format(cell.getNumericCellValue()); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
case STRING: |
|
|
|
cellValue = cell.getStringCellValue(); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
case FORMULA: |
|
|
|
if (DateUtil.isCellDateFormatted(cell)) { |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); |
|
|
|
cellValue = sdf.format(cell.getDateCellValue()); |
|
|
@ -370,13 +370,13 @@ public class PoiUtil { |
|
|
|
cellValue = String.valueOf(cell.getNumericCellValue()); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
case BLANK: |
|
|
|
cellValue = ""; |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
case BOOLEAN: |
|
|
|
cellValue = String.valueOf(cell.getBooleanCellValue()); |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
case ERROR: |
|
|
|
cellValue = String.valueOf(cell.getErrorCellValue()); |
|
|
|
break; |
|
|
|
} |
|
|
@ -513,7 +513,7 @@ public class PoiUtil { |
|
|
|
InputStream inputStream = new FileInputStream(file); |
|
|
|
Workbook workbook; |
|
|
|
if (file.getPath().endsWith(".xls")) { |
|
|
|
workbook = new XSSFWorkbook(inputStream); |
|
|
|
workbook = new HSSFWorkbook(inputStream); |
|
|
|
} else { |
|
|
|
workbook = new XSSFWorkbook(inputStream); |
|
|
|
} |
|
|
|