From 9c48e4696d5448a50579c210fa6291e8d25ab15d Mon Sep 17 00:00:00 2001 From: Black Pan Date: Mon, 17 Jun 2024 14:44:17 +0800 Subject: [PATCH] =?UTF-8?q?feat-=E4=BC=98=E5=8C=96=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=88=A4=E6=96=AD=EF=BC=9A=E6=97=A0=E6=B3=95=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=90=8E=E7=BC=80=E5=90=8D=E5=88=A4=E6=96=AD=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E6=97=B6=EF=BC=8C=E7=9B=B4=E6=8E=A5=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E9=AD=94=E6=B3=95=E6=95=B0=E5=88=A4=E6=96=AD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/alibaba/excel/support/ExcelTypeEnum.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/easyexcel-core/src/main/java/com/alibaba/excel/support/ExcelTypeEnum.java b/easyexcel-core/src/main/java/com/alibaba/excel/support/ExcelTypeEnum.java index 34c584e8..861cd91c 100644 --- a/easyexcel-core/src/main/java/com/alibaba/excel/support/ExcelTypeEnum.java +++ b/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,6 +68,10 @@ public enum ExcelTypeEnum { } else if (fileName.endsWith(CSV.getValue())) { return CSV; } + //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()) { inputStream = new BufferedInputStream(inputStream);