microsoft / microsoft/markitdown
Exclude Hidden Sheets in Excel Conversion
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 186k
- Forks
- 13.7k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 49
Description
When processing Excel files (.xlsx) using the library, the current implementation reads all sheets—including hidden ones—using the following call:
sheets = pd.read_excel(local_path, sheet_name=None, engine="openpyxl")
This behavior results in hidden sheets being processed and included in the final Markdown output, which is not the expected outcome in most cases.
Steps to Reproduce:
- Create or use an Excel workbook that contains both visible and hidden sheets.
- Run the conversion using the
XlsxConverter. - Observe that the output Markdown includes content from both visible and hidden sheets.
Expected Behavior:
Only visible sheets should be processed by default. Ideally, there should be an option to toggle the inclusion of hidden sheets. Filtering out hidden sheets would prevent unintended content from appearing in the converted Markdown.
Potential Solution:
For .xlsx files, one approach could be to use openpyxl to load the workbook and check each sheet’s sheet_state property. For example, you could filter the sheets like so:
wb = load_workbook(local_path, read_only=True, data_only=True)
visible_sheet_names = [sheet.title for sheet in wb.worksheets if sheet.sheet_state == 'visible']
Then pass visible_sheet_names to pd.read_excel instead of reading all sheets.
Note that this solution applies to .xlsx files only, as the engine used for .xls files (e.g., xlrd) does not expose hidden sheet information.
Thank you for considering this enhancement!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at XlsxConverter and the pd.read_excel call shown in the issue. Reproduce the conversion with a workbook containing visible and hidden sheets, then inspect how sheet names are selected for .xlsx files. Done means visible sheets remain in the Markdown while hidden sheets are excluded by default, with any supported inclusion option behaving as documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- pandas, python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100