Browse Source

Merge 23c9e8c89b into aae9c61ab6

pull/3829/merge
psxjoy 6 months ago committed by GitHub
parent
commit
c7618ee39a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 13
      easyexcel-core/src/main/java/com/alibaba/excel/support/ExcelTypeEnum.java

13
easyexcel-core/src/main/java/com/alibaba/excel/support/ExcelTypeEnum.java

@ -59,12 +59,6 @@ public enum ExcelTypeEnum {
if (!file.exists()) {
throw new ExcelAnalysisException("File " + file.getAbsolutePath() + " not exists.");
}
// If there is a password, use the FileMagic first
if (!StringUtils.isEmpty(readWorkbook.getPassword())) {
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) {
return recognitionExcelType(bufferedInputStream);
}
}
// Use the name to determine the type
String fileName = file.getName();
if (fileName.endsWith(XLSX.getValue())) {
@ -74,10 +68,9 @@ public enum ExcelTypeEnum {
} else if (fileName.endsWith(CSV.getValue())) {
return CSV;
}
if (StringUtils.isEmpty(readWorkbook.getPassword())) {
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) {
return recognitionExcelType(bufferedInputStream);
}
//If cannot get the name, use the magic number to determine the type
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) {
return recognitionExcelType(bufferedInputStream);
}
}
if (!inputStream.markSupported()) {

Loading…
Cancel
Save