|
@@ -12,6 +12,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
@@ -63,11 +64,17 @@ public class ExcelUtil {
|
|
|
// 获取Workbook
|
|
|
InputStream inputStream = new BufferedInputStream(new FileInputStream(file));
|
|
|
Workbook wb = null;
|
|
|
- if (filePath.endsWith("xls")) {
|
|
|
- wb = new HSSFWorkbook(inputStream);
|
|
|
- } else {
|
|
|
- wb = new XSSFWorkbook(inputStream);
|
|
|
+ try {
|
|
|
+ wb = WorkbookFactory.create(inputStream);
|
|
|
+ } catch (InvalidFormatException e) {
|
|
|
+ logger.error("readExcelHead error:", e);
|
|
|
+ throw new RuntimeException(e);
|
|
|
}
|
|
|
+// if (filePath.endsWith("xls")) {
|
|
|
+// wb = new HSSFWorkbook(inputStream);
|
|
|
+// } else {
|
|
|
+// wb = new XSSFWorkbook(inputStream);
|
|
|
+// }
|
|
|
inputStream.close();
|
|
|
|
|
|
// 获取Sheet
|