You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2017/01/19 06:43:59 UTC
[Bug 60605] New: Convert Workbook.SHEET_STATE_HIDDEN, VISIBLE, and
VERY_HIDDEN to enum
https://bz.apache.org/bugzilla/show_bug.cgi?id=60605
Bug ID: 60605
Summary: Convert Workbook.SHEET_STATE_HIDDEN, VISIBLE, and
VERY_HIDDEN to enum
Product: POI
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P2
Component: SS Common
Assignee: dev@poi.apache.org
Reporter: onealj@apache.org
Blocks: 59836
Target Milestone: ---
Could be converted to
enum SheetState {
VISIBLE(0),
HIDDEN(1),
VERY_HIDDEN(2);
}
Referenced Bugs:
https://bz.apache.org/bugzilla/show_bug.cgi?id=59836
[Bug 59836] Tracker: Replace primitives with enums
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 60605] Convert Workbook.SHEET_STATE_HIDDEN, VISIBLE, and
VERY_HIDDEN to enum
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60605
--- Comment #5 from Javen O'Neal <on...@apache.org> ---
@Test
public void testActiveSheetIsHidden() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
wb.createSheet("First Sheet");
wb.setSheetVisibility(0, SheetVisibility.HIDDEN);
java.io.FileOutputStream fos = new java.io.FileOutputStream("/tmp/hidden"
+ "." + _testDataProvider.getStandardFileNameExtension());
wb.write(fos);
wb.close();
fos.close();
wb = _testDataProvider.createWorkbook();
wb.createSheet("First Sheet");
wb.setSheetVisibility(0, SheetVisibility.VERY_HIDDEN);
fos = new java.io.FileOutputStream("/tmp/veryhidden"
+ "." + _testDataProvider.getStandardFileNameExtension());
wb.write(fos);
wb.close();
fos.close();
}
Excel 2013 behavior:
hidden.xls and veryhidden.xls open without a warning with no sheets visible.
After adding a sheet to hidden.xls, the menu to unhide the first sheet is
available.
hidden.xlsx and veryhidden.xlsx open with a
> "We found a problem with some content in 'veryhidden.xlsx'. Do you want us to try to recover as much as we can?"
corrupted workbook dialog.
LibreOffice 4.0.4.2 behavior:
all 4 files open with the first sheet visible.
If we implement this to match Excel's behavior, we would have an inconsistency
between HSSF and XSSF.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 60605] Convert Workbook.SHEET_STATE_HIDDEN, VISIBLE, and
VERY_HIDDEN to enum
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60605
--- Comment #1 from Greg Woolsey <gr...@gmail.com> ---
We don't need the instance constructor argument, just use
enumInstance.ordinal()
I do like replacing all integer constants like this with enums.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 60605] Convert Workbook.SHEET_STATE_HIDDEN, VISIBLE, and
VERY_HIDDEN to enum
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60605
--- Comment #4 from Javen O'Neal <on...@apache.org> ---
Created attachment 34653
--> https://bz.apache.org/bugzilla/attachment.cgi?id=34653&action=edit
Code changes for Option 3 and Option 4
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 60605] Convert Workbook.SHEET_STATE_HIDDEN, VISIBLE, and
VERY_HIDDEN to enum
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60605
--- Comment #2 from Javen O'Neal <on...@apache.org> ---
Implemented in r1779558.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 60605] Convert Workbook.SHEET_STATE_HIDDEN, VISIBLE, and
VERY_HIDDEN to enum
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60605
Javen O'Neal <on...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |NEEDINFO
--- Comment #3 from Javen O'Neal <on...@apache.org> ---
While working on this, I read the javadoc comment for setSheetHidden(int
sheetIndex, int state) that the active sheet cannot be hidden, but we do not
enforce this.
Presumably, saving a workbook with a hidden active sheet would result in Excel
complaining about a corrupted workbook when opened (untested).
There are a few ways we can handle this:
1) Make the recommendation in the javadoc but do not enforce this rule
2) Option 1 plus logging a warning that an active sheet was hidden
3) throw an IllegalStateException when trying to hide an active sheet
4) Activate the next visible sheet if hiding the active sheet. Log a warning
that setSheetVisibility had this un-asked for side-effect. If there are no
other visible sheets, throw an IllegalStateException (this is closest to what
Excel does, but may make for some rare bugs).
5) Same as number 4, but defer checking until saving the workbook (throwing an
IllegalStateException at this point would be fatal and could cause problems if
the workbook is partially serialized).
Which behavior is least surprising?
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org