Skip to content

fix: read encrypted xlsx file exception #394

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

Merged
merged 5 commits into from
Jul 17, 2025
Merged

Conversation

delei
Copy link
Collaborator

@delei delei commented Jun 24, 2025

Close #393

What's changed?

  • enhance type recognition by considering password-protected files
  • refactor encryption test cases

Checklist

  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

@psxjoy psxjoy requested a review from Copilot July 8, 2025 11:48
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances Excel type detection for password-protected files and refactors the encryption-related test cases to support XLSX, XLS, and CSV in both file and stream modes.

  • Enhanced ExcelTypeEnum.valueOf to recognize file type before and after password checks.
  • Refactored EncryptDataTest to parameterize read/write scenarios across XLSX, XLS, and CSV.
  • Updated test listener and model to use Lombok logging and consistent data naming.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
fastexcel-test/src/test/java/cn/idev/excel/test/core/encrypt/EncryptDataTest.java Refactored and parameterized encryption tests to support XLSX, XLS, and CSV with streaming options
fastexcel-test/src/test/java/cn/idev/excel/test/core/encrypt/EncryptDataListener.java Added logging with Lombok’s @Slf4j and updated assertions in data listener
fastexcel-test/src/test/java/cn/idev/excel/test/core/encrypt/EncryptData.java Added @ToString to test data model
fastexcel-core/src/main/java/cn/idev/excel/support/ExcelTypeEnum.java Enhanced ExcelTypeEnum recognition to handle password-protected files
Comments suppressed due to low confidence (1)

fastexcel-core/src/main/java/cn/idev/excel/support/ExcelTypeEnum.java:55

  • StringUtils is not imported; add the appropriate import (e.g., import cn.idev.excel.util.StringUtils;) to avoid compilation errors.
        boolean hasPassword = !StringUtils.isEmpty(readWorkbook.getPassword());

Copy link
Member

@psxjoy psxjoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+LGTM
If no one else has a problem with it, I'll merge it into the main branch this week :)

@psxjoy psxjoy merged commit 89bc557 into fast-excel:main Jul 17, 2025
4 checks passed
@delei delei deleted the issue/fix-393 branch July 17, 2025 17:28
@delei delei added this to the 1.3.0 milestone Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] read encrypted xlsx file exception
3 participants