ENH: Adding 'hidden=True' to 'to_excel', or efficiently hiding some excel tabs?
See original GitHub issueI need to hide some excel tabs in an output from to_excel, and I’d like to do that with a parameter like hidden=True, but no such parameter exists. The only solution I can find is hiding the sheet manually with openpyxl, but this is prohibitively slow for large files.
My StackOverflow question on this is unanswered, which suggests I’m out of luck.
Testing openpyxl showed that we can’t save .xlsxs without at least one visible tab, so it looks like this would only work like so:
writer = pd.ExcelWriter(filename, engine='xlsxwriter')
with writer:
df.to_excel(writer, sheet_name='df')
df.to_excel(writer, sheet_name='2nd tab')
Would adding hidden=True to to_excel be practical?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Hide or Unhide worksheets - Microsoft Support
Learn to hide (or unhide) worksheet tabs or workbooks in Excel. ... Right-click the sheet tab you want to hide, or any visible...
Read more >Pandas to_excel with sheets being hidden, or efficiently hiding ...
I'd like to add something like hidden=True to a sheet condition but pandas doesn't seem to support this. We can do this manually...
Read more >Pandas To_Excel With Sheets Being Hidden, Or Efficiently ...
Ask questionsENH: Adding 'hiddenTrue' to 'toexcel' or efficiently hiding some excel tabs? I need to hide some excel tabs in an output from...
Read more >How to make Excel worksheet very hidden and unhide it
All you have to do is right-click any visible worksheet, click Unhide, and select the sheet you want to view. Very hidden sheets...
Read more >11 Ways to Hide a Sheet in Microsoft Excel
This post is going to show you all the ways to hide any sheet tab in your workbook. Excel allows users to create...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

There are some potential issues with this proposal. The first is that any parameter added to
to_excel()has to be supported by all the Excel engines. In addition, there are a lot of parameters and methods that are exposed by XlsxWriter and OpenPyXL (and xlwt) and it wouldn’t be feasible to add them all to theto_excel()interface (in fact it probably already has too many). Finally, there is a technical issue where hiding the active worksheet without activating another worksheet would generate a “corrupt” Excel file that would open with errors.So my vote is to close this as can’t fix/won’t fix. Apologies in advance.
I don’t think there is any further action required here - @chrisjdixon thanks for the report! If you feel something is still unresolved, simply reply here and can reopen.