Bug 56129 - XSSFWorkBook.setSheetHidden(0, true) does not hide the first sheet
Summary: XSSFWorkBook.setSheetHidden(0, true) does not hide the first sheet
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.9-FINAL
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-12 14:22 UTC by Eli Vingot
Modified: 2015-09-13 19:34 UTC (History)
0 users



Attachments
first sheet hidden saved by Excel (works fine) (8.18 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2014-02-12 15:40 UTC, Eli Vingot
Details
second sheet hidden, saved by poi 3.10 (works fine) (3.94 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2014-02-12 15:40 UTC, Eli Vingot
Details
first sheet hidden, saved by poi 3.10 (Does not work, sheet is visible) (3.94 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2014-02-12 15:41 UTC, Eli Vingot
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eli Vingot 2014-02-12 14:22:18 UTC
setSheetHidden() does not work on the first sheet, it works fine on other sheets.





Workbook wb = new XSSFWorkbook();
wb.createSheet("first");
wb.createSheet("second");
wb.createSheet("third");

wb.setSheetHidden(0, true);  // this does not work
wb.setSheetHidden(1, true);  // this works

fileOut = new FileOutputStream("workbook.xlsx");
wb.write(fileOut);
fileOut.close();
Comment 1 Eli Vingot 2014-02-12 14:24:12 UTC
Looking at the ctSheet after the call I see that it is set as "hidden".
Comment 2 Nick Burch 2014-02-12 14:29:01 UTC
First up, any chance you could re-test with the new POI 3.10 final?

Secondly, are you able to produce 3 files:
 * POI produced, sheet 0 hidden
 * POI produced, sheet 1 hidden
 * Excel produced, sheet 0 hidden
?

Thirdly, could either you, or someone else, unzip the three .xlsx files (which are zips of xml), and then compare where and what gets set around hidden sheets, to see if we can identify what POI's doing wrong?
Comment 3 Eli Vingot 2014-02-12 15:40:02 UTC
Created attachment 31302 [details]
first sheet hidden saved by Excel  (works fine)
Comment 4 Eli Vingot 2014-02-12 15:40:46 UTC
Created attachment 31303 [details]
second sheet hidden, saved by poi 3.10  (works fine)
Comment 5 Eli Vingot 2014-02-12 15:41:48 UTC
Created attachment 31304 [details]
first sheet hidden, saved by poi 3.10 (Does not work, sheet is visible)
Comment 6 Eli Vingot 2014-02-12 15:58:10 UTC
Looked at inside the zipped xlsx and mystery solved.
Problem is that the active sheet cannot be hidden.

When changing the code to:

wb.setActiveSheet(1);
wb.setSheetHidden(0, true);

The first sheet is hidden correctly.

I still thinks this is a bug but not as critical as before
Comment 7 Nick Burch 2014-02-12 16:03:21 UTC
Any chance you could propose a tweak to the setSheetHidden javadocs to add the note about active sheets? That should hopefully help someone in your situation in future!
Comment 8 Dominik Stadler 2015-09-13 19:34:47 UTC
I have now updated the javadoc for the relevant methods in Workbook, XSSFWorkbook and SXSSFWorkbook via r1702805. For now we will not perform more checks here as the spec seems to allow these settings and Excel just interprets them this way currently.