Skip to content

Exclude hidden worksheets by default in XLSX conversion - #2563

Open
Siddlab (SiddarthaK16) wants to merge 2 commits into
microsoft:mainfrom
SiddarthaK16:fix/xlsx-ignore-hidden-sheets-1073
Open

Siddlab (SiddarthaK16) wants to merge 2 commits into
microsoft:mainfrom
SiddarthaK16:fix/xlsx-ignore-hidden-sheets-1073

Conversation

@SiddarthaK16

Copy link
Copy Markdown

Summary

  • Exclude hidden and very hidden worksheets from XLSX conversion by default.
  • Add a Python option and CLI flag to include hidden worksheets when needed.
  • Document the opt-in and cover default and opt-in behavior with tests.

Closes #1073.

PR #2456 also addresses hidden worksheets, but keeps them included by default for compatibility. This PR follows issue #1073's request for visible-only output by default, with an explicit opt-in for the previous behavior.

@SiddarthaK16

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@UmeshCode1 Umesh Patel (UmeshCode1) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Very clean implementation and well-aligned with #1073.

A few notable positive aspects of this design:

  1. Stream Hygiene: In _get_visible_sheet_names, opening with read_only=True avoids loading entire cell matrices just to inspect sheet visibility metadata, and ensuring workbook.close() + file_stream.seek(start_pos) inside finally prevents stream pointer corruption for downstream converters or repair passes.
  2. Empty Edge-Case Safety: The if not sheet_names: return {} guard cleanly avoids pd.read_excel throwing when passed an empty list if a workbook has all sheets marked hidden.
  3. CLI & Python Option Symmetry: Passing **conversion_options to both convert() and convert_stream() keeps CLI and programmatic usage uniform.
  4. Test Coverage: Explicitly asserting both hidden and veryHidden sheets in the test suite verifies the complete OpenXML visibility spec.

LGTM!

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.

Exclude Hidden Sheets in Excel Conversion

2 participants