Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat-删除文件加密时的无效判断。 #3829

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ public static ExcelTypeEnum valueOf(ReadWorkbook readWorkbook) {
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())) {
Expand All @@ -74,10 +68,9 @@ public static ExcelTypeEnum valueOf(ReadWorkbook readWorkbook) {
} 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()) {
Expand Down