Created attachment 35476 [details] Empty workbook with a hidden workbook view From Users@POI mailing list: https://lists.apache.org/thread.html/4c6b6800d165d90374d3ad3ea49bbd1509c3a4d0dc093d0f1d597965@%3Cuser.poi.apache.org%3E I was able to create a hidden window in Microsoft Excel 2013 only when there were multiple views of a workbook open. View > Window > New Window to create a 2nd view of the active workbook View > Window > Hide to hide the active view of the active workbook In the XML: xl/workbook.xml: <workbook xmlns="..." ...> ... <bookViews> <workbookView xWindow="0" yWindow="0" windowWidth="16920" windowHeight="10980"/> + <workbookView visibility="hidden" xWindow="0" yWindow="0" windowWidth="16920" windowHeight="10980"/> </bookViews> ... </workbook> xl/worksheets/sheet1.xml: <worksheet xmlns="..." ...> ... <sheetViews> <sheetView tabSelected="1" workbookViewId="0"/> + <sheetView tabSelected="1" workbookViewId="1"/> </sheetViews> ... </worksheet>
HSSFWorkbook implemented isHidden/setHidden as the visibility of the first workbook view (InternalWorkbook.getWindowOne().getHidden()). The correct behavior would seem to let the user specify the index of the window (view) and return the visibility of that window (view). POI currently doesn't have functions for creating workbook views. Being that Microsoft Excel doesn't allow you to hide every window view of a workbook, it's likely you'll end up with a corrupt workbook if you hide the only view on a workbook.
Created attachment 35477 [details] Patch to add isHidden(), setHidden(boolean), isHidden(int), setHidden(int, boolean) Being able to set workbook window views as hidden isn't very useful without being able to create and delete workbook views. This gets more complicated because of bookviews and sheetviews > CTWorkbook.getBookViews().addNewWorkbookView(); > CTWorkbook.getBookViews().removeWorkbookView(int i); http://www.datypic.com/sc/ooxml/e-ssml_workbookView-1.html http://www.datypic.com/sc/ooxml/e-ssml_customWorkbookView-1.html http://www.datypic.com/sc/ooxml/a-visibility-1.html
Comments from Mark: In my testing, Excel 2016, I can hide a workbook by selecting View->Hide. I can do that even if it is the only workbook open. The XML is in workbook.xml and looks like this: <bookViews> <workbookView windowHeight="9600" windowWidth="17595" yWindow="255" xWindow="225" visibility="hidden"/> </bookViews> I can close out of Excel with the only workbook hidden, and it allows me to save it as hidden. When I re-open that workbook, it starts out hidden. --------------------------------------------------------------------- For sheets, once again Excel 2016, I cannot hide the last visible sheet. So it appears that Excel handles Sheets and workbooks differently. One potential reason to have hidden workbooks is if you have a workbook with just macros in it, and you have that in your XLSTART library [User library]/AppData/Roaming/Microsoft/Excel/XLSTART, then that workbook will open every time you open Excel, and you really want that workbook to be hidden, but open with no visible window views.