Skip to content

Fix loading Excel files with pictures having forbidden characters in names #2716

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

laszlozold
Copy link

Allow loading Excel files that contain pictures with names having characters that ClosedXML normally forbids (like backslash, colon, etc). This commonly occurs when loading files created by other applications.

  • Add optional validateName parameter to XLPicture.SetName method
  • Skip validation when loading pictures from existing Excel files
  • Maintain validation for user-created pictures through public API
  • Add comprehensive unit tests for the new functionality

Fixes issue where files with picture names like "Picture@01\QPosted@" couldn't be loaded.

…names

Allow loading Excel files that contain pictures with names having characters
that ClosedXML normally forbids (like backslash, colon, etc). This commonly
occurs when loading files created by other applications.

- Add optional validateName parameter to XLPicture.SetName method
- Skip validation when loading pictures from existing Excel files
- Maintain validation for user-created pictures through public API
- Add comprehensive unit tests for the new functionality

Fixes issue where files with picture names like "Picture@01\QPosted@"
couldn't be loaded.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@laszlozold
Copy link
Author

Hi @jahav, @igitur, @Pankraty,

I've created issue #2727 with a reproducible test case for this bug. This PR fixes
a problem where valid Excel files (that open fine in Excel/LibreOffice) cannot be
loaded by ClosedXML due to picture name validation.

The fix is minimal - it just removes the overly restrictive validation during loading
while keeping it for creation (to maintain Excel compatibility).

Would appreciate a review when you have time. Happy to make any adjustments needed.

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.

1 participant