diff --git a/main/HSSF/Model/InternalWorkbook.cs b/main/HSSF/Model/InternalWorkbook.cs index 6dc7c4a12..c2b6f7bf6 100644 --- a/main/HSSF/Model/InternalWorkbook.cs +++ b/main/HSSF/Model/InternalWorkbook.cs @@ -775,6 +775,31 @@ public bool IsSheetVeryHidden(int sheetnum) { return GetBoundSheetRec(sheetnum).IsVeryHidden; } + + /** + * Gets the hidden flag for a given sheet. + * Note that a sheet could instead be + * set to be very hidden, which is different + * ({@link #isSheetVeryHidden(int)}) + * + * @param sheetnum the sheet number (0 based) + * @return True if sheet is hidden + * @since 3.16 beta 2 + */ + public SheetVisibility GetSheetVisibility(int sheetnum) + { + BoundSheetRecord bsr = GetBoundSheetRec(sheetnum); + if(bsr.IsVeryHidden) + { + return SheetVisibility.VeryHidden; + } + if(bsr.IsHidden) + { + return SheetVisibility.Hidden; + } + return SheetVisibility.Visible; + } + /** * Hide or Unhide a sheet * @@ -784,40 +809,19 @@ public bool IsSheetVeryHidden(int sheetnum) public void SetSheetHidden(int sheetnum, bool hidden) { - BoundSheetRecord bsr = boundsheets[sheetnum]; - bsr.IsHidden=hidden; + SetSheetHidden(sheetnum, hidden ? SheetVisibility.Hidden : SheetVisibility.Visible); } /** - * Hide or unhide a sheet. - * 0 = not hidden - * 1 = hidden - * 2 = very hidden. - * - * @param sheetnum The sheet number - * @param hidden 0 for not hidden, 1 for hidden, 2 for very hidden - */ - public void SetSheetHidden(int sheetnum, int hidden) + * Hide or unhide a sheet. + * + * @param sheetnum The sheet number + * @param visibility the sheet visibility to set (visible, hidden, very hidden) + */ + public void SetSheetHidden(int sheetnum, SheetVisibility visibility) { BoundSheetRecord bsr = GetBoundSheetRec(sheetnum); - bool h = false; - bool vh = false; - if (hidden == 0) - { - } - else if (hidden == 1) - { - h = true; - } - else if (hidden == 2) - { - vh = true; - } - else - { - throw new ArgumentException("Invalid hidden flag " + hidden + " given, must be 0, 1 or 2"); - } - bsr.IsHidden = (h); - bsr.IsVeryHidden = (vh); + bsr.IsHidden = visibility == SheetVisibility.Hidden; + bsr.IsVeryHidden = visibility == SheetVisibility.VeryHidden; } /** * Get the sheet's index diff --git a/main/HSSF/UserModel/HSSFWorkbook.cs b/main/HSSF/UserModel/HSSFWorkbook.cs index 9199ce3eb..ab0f462c8 100644 --- a/main/HSSF/UserModel/HSSFWorkbook.cs +++ b/main/HSSF/UserModel/HSSFWorkbook.cs @@ -759,32 +759,57 @@ public bool IsSheetVeryHidden(int sheetIx) ValidateSheetIndex(sheetIx); return workbook.IsSheetVeryHidden(sheetIx); } + + public SheetVisibility GetSheetVisibility(int sheetIx) + { + return workbook.GetSheetVisibility(sheetIx); + } + /// /// Hide or Unhide a sheet /// /// The sheet index - /// True to mark the sheet as hidden, false otherwise - public void SetSheetHidden(int sheetIx, SheetState hidden) + /// + [Obsolete] + public void SetSheetHidden(int sheetIx, SheetVisibility hidden) { - ValidateSheetIndex(sheetIx); - WorkbookUtil.ValidateSheetState(hidden); - workbook.SetSheetHidden(sheetIx, (int)hidden); + SetSheetVisibility(sheetIx, hidden); } /// /// Hide or unhide a sheet. /// /// The sheet number /// 0 for not hidden, 1 for hidden, 2 for very hidden + [Obsolete] public void SetSheetHidden(int sheetIx, int hidden) { - ValidateSheetIndex(sheetIx); - workbook.SetSheetHidden(sheetIx, hidden); + switch(hidden) + { + case 0: + SetSheetVisibility(sheetIx, SheetVisibility.Visible); + break; + case 1: + SetSheetVisibility(sheetIx, SheetVisibility.Hidden); + break; + case 2: + SetSheetVisibility(sheetIx, SheetVisibility.VeryHidden); + break; + default: + throw new ArgumentException("Invalid sheet state : " + hidden + "\n" + + "Sheet state must beone of the Workbook.SHEET_STATE_* constants"); + } } public void SetSheetHidden(int sheetIx, bool hidden) + { + SetSheetVisibility(sheetIx, hidden ? SheetVisibility.Hidden : SheetVisibility.Visible); + } + + public void SetSheetVisibility(int sheetIx, SheetVisibility visibility) { ValidateSheetIndex(sheetIx); - workbook.SetSheetHidden(sheetIx, hidden); + workbook.SetSheetHidden(sheetIx, visibility); } + /// /// Returns the index of the sheet by his name /// diff --git a/main/SS/UserModel/SheetVisibility.cs b/main/SS/UserModel/SheetVisibility.cs new file mode 100644 index 000000000..2cc1a8e4d --- /dev/null +++ b/main/SS/UserModel/SheetVisibility.cs @@ -0,0 +1,45 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for Additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +namespace NPOI.SS.UserModel +{ + /// + /// Specifies sheet visibility + /// + public enum SheetVisibility : int + { + /// + /// Indicates the sheet is visible. + /// + Visible = 0, + + /// + /// Indicates the book window is hidden, but can be shown by the user via the user interface. + /// + Hidden = 1, + + /// + /// Indicates the sheet is hidden and cannot be shown in the user interface (UI). + /// + /// + /// In Excel this state is only available programmatically in VBA: + /// ThisWorkbook.Sheets("MySheetName").Visible = xlSheetVeryHidden + /// + /// + VeryHidden = 2 + } +} diff --git a/main/SS/UserModel/Workbook.cs b/main/SS/UserModel/Workbook.cs index 8fb90c985..bff3a26ca 100644 --- a/main/SS/UserModel/Workbook.cs +++ b/main/SS/UserModel/Workbook.cs @@ -24,29 +24,6 @@ namespace NPOI.SS.UserModel using System.Collections.Generic; using NPOI.Util; - public enum SheetState : int - { - /// - /// Indicates the sheet is visible. - /// - Visible = 0, - - /// - /// Indicates the book window is hidden, but can be shown by the user via the user interface. - /// - Hidden = 1, - - /// - /// Indicates the sheet is hidden and cannot be shown in the user interface (UI). - /// - /// - /// In Excel this state is only available programmatically in VBA: - /// ThisWorkbook.Sheets("MySheetName").Visible = xlSheetVeryHidden - /// - /// - VeryHidden = 2 - } - /// /// High level interface of a Excel workbook. This is the first object most users /// will construct whether they are reading or writing a workbook. It is also the @@ -416,7 +393,7 @@ public interface IWorkbook : ICloseable, IDisposable * @param sheetIx the sheet index (0-based) * @param hidden True to mark the sheet as hidden, false otherwise */ - void SetSheetHidden(int sheetIx, SheetState hidden); + void SetSheetHidden(int sheetIx, SheetVisibility hidden); /** * Hide or unhide a sheet. @@ -428,8 +405,30 @@ public interface IWorkbook : ICloseable, IDisposable * @param sheetIx The sheet number * @param hidden 0 for not hidden, 1 for hidden, 2 for very hidden */ + [Obsolete] void SetSheetHidden(int sheetIx, int hidden); + /** + * Get the visibility (visible, hidden, very hidden) of a sheet in this workbook + * + * @param sheetIx the index of the sheet + * @return the sheet visibility + * @since POI 3.16 beta 2 + */ + SheetVisibility GetSheetVisibility(int sheetIx); + + /** + * Hide or unhide a sheet. + * + * Please note that the sheet currently set as active sheet (sheet 0 in a newly + * created workbook or the one set via setActiveSheet()) cannot be hidden. + * + * @param sheetIx the sheet index (0-based) + * @param visibility the sheet visibility to set + * @since POI 3.16 beta 2 + */ + void SetSheetVisibility(int sheetIx, SheetVisibility visibility); + /// /// Register a new toolpack in this workbook. /// @@ -444,7 +443,7 @@ public interface IWorkbook : ICloseable, IDisposable /// True if the date systems used in the workbook starts in 1904 bool IsDate1904(); - void Close(); + //void Close(); /// /// Returns the spreadsheet version (EXCLE97) of this workbook diff --git a/main/SS/Util/WorkbookUtil.cs b/main/SS/Util/WorkbookUtil.cs index 2866c5d94..4124e3129 100644 --- a/main/SS/Util/WorkbookUtil.cs +++ b/main/SS/Util/WorkbookUtil.cs @@ -4,156 +4,208 @@ namespace NPOI.SS.Util { -/** - * Helper methods for when working with Usermodel Workbooks - */ -public class WorkbookUtil { - /** - * Creates a valid sheet name, which is conform to the rules. - * In any case, the result safely can be used for - * {@link org.apache.poi.ss.usermodel.Workbook#setSheetName(int, String)}. - *
- * Rules: - * - * Invalid characters are replaced by one space character ' '. - * - * @param nameProposal can be any string, will be truncated if necessary, - * allowed to be null - * @return a valid string, "empty" if to short, "null" if null + * Helper methods for when working with Usermodel Workbooks */ - public static String CreateSafeSheetName(String nameProposal) + public class WorkbookUtil { - return CreateSafeSheetName(nameProposal, ' '); - } - /** - * Creates a valid sheet name, which is conform to the rules. - * In any case, the result safely can be used for - * {@link org.apache.poi.ss.usermodel.Workbook#setSheetName(int, String)}. - *
- * Rules: - * - * - * @param nameProposal can be any string, will be truncated if necessary, - * allowed to be null - * @param replaceChar the char to replace invalid characters. - * @return a valid string, "empty" if to short, "null" if null - */ - public static String CreateSafeSheetName(String nameProposal, char replaceChar) { - if (nameProposal == null) { - return "null"; - } - if (nameProposal.Length < 1) { - return "empty"; + + /** + * Creates a valid sheet name, which is conform to the rules. + * In any case, the result safely can be used for + * {@link org.apache.poi.ss.usermodel.Workbook#setSheetName(int, String)}. + *
+ * Rules: + * + * Invalid characters are replaced by one space character ' '. + * + * @param nameProposal can be any string, will be truncated if necessary, + * allowed to be null + * @return a valid string, "empty" if to short, "null" if null + */ + public static String CreateSafeSheetName(String nameProposal) + { + return CreateSafeSheetName(nameProposal, ' '); } - int length = Math.Min(31, nameProposal.Length); - String shortenname = nameProposal.Substring(0, length); - StringBuilder result = new StringBuilder(shortenname); - for (int i=0; i + * Rules: + *
    + *
  • never null
  • + *
  • minimum length is 1
  • + *
  • maximum length is 31
  • + *
  • doesn't contain special chars: : 0x0000, 0x0003, / \ ? * ] [
  • + *
  • Sheet names must not begin or end with ' (apostrophe)
  • + *
+ * + * @param nameProposal can be any string, will be truncated if necessary, + * allowed to be null + * @param replaceChar the char to replace invalid characters. + * @return a valid string, "empty" if to short, "null" if null + */ + public static String CreateSafeSheetName(String nameProposal, char replaceChar) + { + if(nameProposal == null) + { + return "null"; + } + if(nameProposal.Length < 1) + { + return "empty"; + } + int length = Math.Min(31, nameProposal.Length); + String shortenname = nameProposal.Substring(0, length); + StringBuilder result = new StringBuilder(shortenname); + for(int i = 0; i - * The character count MUST be greater than or equal to 1 and less than or equal to 31. - * The string MUST NOT contain the any of the following characters: - *
    - *
  • 0x0000
  • - *
  • 0x0003
  • - *
  • colon (:)
  • - *
  • backslash (\)
  • - *
  • asterisk (*)
  • - *
  • question mark (?)
  • - *
  • forward slash (/)
  • - *
  • opening square bracket ([)
  • - *
  • closing square bracket (])
  • - *
- * The string MUST NOT begin or end with the single quote (') character. - *

- * - * @param sheetName the name to validate - */ - public static void ValidateSheetName(String sheetName) { - if (sheetName == null) { - throw new ArgumentException("sheetName must not be null"); - } - int len = sheetName.Length; - if (len < 1 || len > 31) { - throw new ArgumentException("sheetName '" + sheetName - + "' is invalid - character count MUST be greater than or equal to 1 and less than or equal to 31"); + /** + * Validates sheet name. + * + *

+ * The character count MUST be greater than or equal to 1 and less than or equal to 31. + * The string MUST NOT contain the any of the following characters: + *

    + *
  • 0x0000
  • + *
  • 0x0003
  • + *
  • colon (:)
  • + *
  • backslash (\)
  • + *
  • asterisk (*)
  • + *
  • question mark (?)
  • + *
  • forward slash (/)
  • + *
  • opening square bracket ([)
  • + *
  • closing square bracket (])
  • + *
+ * The string MUST NOT begin or end with the single quote (') character. + *

+ * + * @param sheetName the name to validate + */ + public static void ValidateSheetName(String sheetName) + { + if(sheetName == null) + { + throw new ArgumentException("sheetName must not be null"); + } + int len = sheetName.Length; + if(len < 1 || len > 31) + { + throw new ArgumentException("sheetName '" + sheetName + + "' is invalid - character count MUST be greater than or equal to 1 and less than or equal to 31"); + } + + for(int i = 0; i /// Returns the spreadsheet version (EXCLE2007) of this workbook diff --git a/ooxml/XSSF/UserModel/XSSFWorkbook.cs b/ooxml/XSSF/UserModel/XSSFWorkbook.cs index da0981aa7..e449ad1db 100644 --- a/ooxml/XSSF/UserModel/XSSFWorkbook.cs +++ b/ooxml/XSSF/UserModel/XSSFWorkbook.cs @@ -1993,6 +1993,26 @@ public bool IsSheetVeryHidden(int sheetIx) return ctSheet.state == ST_SheetState.veryHidden; } + public SheetVisibility GetSheetVisibility(int sheetIx) + { + ValidateSheetIndex(sheetIx); + CT_Sheet ctSheet = sheets[sheetIx].sheet; + ST_SheetState state = ctSheet.state; + if(state == ST_SheetState.visible) + { + return SheetVisibility.Visible; + } + if(state == ST_SheetState.hidden) + { + return SheetVisibility.Hidden; + } + if(state == ST_SheetState.veryHidden) + { + return SheetVisibility.VeryHidden; + } + throw new ArgumentException("This should never happen"); + } + /** * Sets the visible state of this sheet. *

@@ -2009,7 +2029,7 @@ public bool IsSheetVeryHidden(int sheetIx) */ public void SetSheetHidden(int sheetIx, bool hidden) { - SetSheetHidden(sheetIx, hidden ? SheetState.Hidden : SheetState.Visible); + SetSheetHidden(sheetIx, hidden ? SheetVisibility.Hidden : SheetVisibility.Visible); } /** @@ -2027,12 +2047,10 @@ public void SetSheetHidden(int sheetIx, bool hidden) * Workbook.SHEET_STATE_VERY_HIDDEN. * @throws ArgumentException if the supplied sheet index or state is invalid */ - public void SetSheetHidden(int sheetIx, SheetState state) + [Obsolete] + public void SetSheetHidden(int sheetIx, SheetVisibility state) { - ValidateSheetIndex(sheetIx); - WorkbookUtil.ValidateSheetState(state); - CT_Sheet ctSheet = sheets[sheetIx].sheet; - ctSheet.state = (ST_SheetState)state; + SetSheetVisibility(sheetIx, state); } ///

@@ -2040,10 +2058,32 @@ public void SetSheetHidden(int sheetIx, SheetState state) /// /// The sheet number /// 0 for not hidden, 1 for hidden, 2 for very hidden - public void SetSheetHidden(int sheetIx, int hidden) + [Obsolete] + public void SetSheetHidden(int sheetIx, int state) + { + WorkbookUtil.ValidateSheetState((SheetVisibility)state); + SetSheetVisibility(sheetIx, (SheetVisibility) state); + } + + public void SetSheetVisibility(int sheetIx, SheetVisibility visibility) { ValidateSheetIndex(sheetIx); - this.SetSheetHidden(sheetIx, (SheetState)hidden); + + CT_Sheet ctSheet = sheets[sheetIx].sheet; + switch(visibility) + { + case SheetVisibility.Visible: + ctSheet.state = (ST_SheetState.visible); + break; + case SheetVisibility.Hidden: + ctSheet.state = (ST_SheetState.hidden); + break; + case SheetVisibility.VeryHidden: + ctSheet.state = (ST_SheetState.veryHidden); + break; + default: + throw new ArgumentException("This should never happen"); + } } /** diff --git a/testcases/main/HSSF/UserModel/TestBugs.cs b/testcases/main/HSSF/UserModel/TestBugs.cs index 60d7ab955..c34b07ba4 100644 --- a/testcases/main/HSSF/UserModel/TestBugs.cs +++ b/testcases/main/HSSF/UserModel/TestBugs.cs @@ -1601,8 +1601,8 @@ public void Test45761() Assert.IsFalse(wb.IsSheetHidden(2)); Assert.IsTrue(wb.IsSheetVeryHidden(2)); - // Change 0 to be very hidden, and re-load - wb.SetSheetHidden(0, 2); + // Change sheet 0 to be very hidden, and re-load + wb.SetSheetVisibility(0, SheetVisibility.VeryHidden); HSSFWorkbook nwb = WriteOutAndReadBack(wb); @@ -1614,76 +1614,59 @@ public void Test45761() Assert.IsTrue(nwb.IsSheetVeryHidden(2)); } - ///** - // * header / footer text too long - // */ - //[Test] - //public void Test45777() - //{ - // HSSFWorkbook wb = new HSSFWorkbook(); - // Sheet s = wb.CreateSheet(); - - // String s248 = ""; - // for (int i = 0; i < 248; i++) - // { - // s248 += "x"; - // } - // String s249 = s248 + "1"; - // String s250 = s248 + "12"; - // String s251 = s248 + "123"; - // Assert.AreEqual(248, s248.Length); - // Assert.AreEqual(249, s249.Length); - // Assert.AreEqual(250, s250.Length); - // Assert.AreEqual(251, s251.Length); - - - // // Try on headers - // s.Header.Center = (s248); - // Assert.AreEqual(254, s.Header.RawHeader.Length); - // WriteOutAndReadBack(wb); - - // s.Header.Center = (s249); - // Assert.AreEqual(255, s.Header.RawHeader.Length); - // WriteOutAndReadBack(wb); - - // try - // { - // s.Header.Center = (s250); // 256 - // Assert.Fail(); - // } - // catch (ArgumentException e) { } - - // try - // { - // s.Header.Center = (s251); // 257 - // Assert.Fail(); - // } - // catch (ArgumentException e) { } - - - // // Now try on footers - // s.Footer.Center = (s248); - // Assert.AreEqual(254, s.Footer.RawFooter.Length); - // WriteOutAndReadBack(wb); - - // s.Footer.Center = (s249); - // Assert.AreEqual(255, s.Footer.RawFooter.Length); - // WriteOutAndReadBack(wb); - - // try - // { - // s.Footer.Center = (s250); // 256 - // Assert.Fail(); - // } - // catch (ArgumentException e) { } - - // try - // { - // s.Footer.Center = (s251); // 257 - // Assert.Fail(); - // } - // catch (ArgumentException e) { } - //} + /// + /// The resolution for bug 45777 assumed that the maximum text length in a header / footer + /// record was 256 bytes. This assumption appears to be wrong. Since the fix for bug 47244, + /// POI now supports header / footer text lengths beyond 256 bytes. + /// + [Test] + public void Bug45777() + { + + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet s = wb.CreateSheet() as HSSFSheet; + + char[] cc248 = new char[248]; + Arrays.Fill(cc248, 'x'); + String s248 = new String(cc248); + + String s249 = s248 + "1"; + String s250 = s248 + "12"; + String s251 = s248 + "123"; + Assert.AreEqual(248, s248.Length); + Assert.AreEqual(249, s249.Length); + Assert.AreEqual(250, s250.Length); + Assert.AreEqual(251, s251.Length); + + + // Try on headers + s.Header.Center = (s248); + Assert.AreEqual(254, (s.Header as HSSFHeader).RawText.Length); + WriteOutAndReadBack(wb).Close(); + + s.Header.Center = (s251); + Assert.AreEqual(257, (s.Header as HSSFHeader).RawText.Length); + WriteOutAndReadBack(wb).Close(); + + // header can be more than 256 bytes + s.Header.Center = (s250); // 256 bytes required + s.Header.Center = (s251); // 257 bytes required + + // Now try on footers + s.Footer.Center = (s248); + Assert.AreEqual(254, (s.Footer as HSSFFooter).RawText.Length); + WriteOutAndReadBack(wb).Close(); + + s.Footer.Center = (s251); + Assert.AreEqual(257, (s.Footer as HSSFFooter).RawText.Length); + WriteOutAndReadBack(wb).Close(); + + // footer can be more than 256 bytes + s.Footer.Center = (s250); // 256 bytes required + s.Footer.Center = (s251); // 257 bytes required + + wb.Close(); + } /** * Charts with long titles diff --git a/testcases/main/SS/UserModel/BaseTestSheetHiding.cs b/testcases/main/SS/UserModel/BaseTestSheetHiding.cs index 629cda3d4..c9a6fb1af 100644 --- a/testcases/main/SS/UserModel/BaseTestSheetHiding.cs +++ b/testcases/main/SS/UserModel/BaseTestSheetHiding.cs @@ -58,7 +58,8 @@ public void SetUp() } [Test] - public void TestSheetHidden() + [Obsolete] + public void TestSheetHiddenOld() { IWorkbook wb = _testDataProvider.CreateWorkbook(); wb.CreateSheet("MySheet"); @@ -66,15 +67,15 @@ public void TestSheetHidden() Assert.IsFalse(wb.IsSheetHidden(0)); Assert.IsFalse(wb.IsSheetVeryHidden(0)); - wb.SetSheetHidden(0, SheetState.Hidden); + wb.SetSheetHidden(0, SheetVisibility.Hidden); Assert.IsTrue(wb.IsSheetHidden(0)); Assert.IsFalse(wb.IsSheetVeryHidden(0)); - wb.SetSheetHidden(0, SheetState.VeryHidden); + wb.SetSheetHidden(0, SheetVisibility.VeryHidden); Assert.IsFalse(wb.IsSheetHidden(0)); Assert.IsTrue(wb.IsSheetVeryHidden(0)); - wb.SetSheetHidden(0, SheetState.Visible); + wb.SetSheetHidden(0, SheetVisibility.Visible); Assert.IsFalse(wb.IsSheetHidden(0)); Assert.IsFalse(wb.IsSheetVeryHidden(0)); @@ -100,6 +101,34 @@ public void TestSheetHidden() wb.Close(); } + [Test] + public void TestSheetVisibility() + { + IWorkbook wb = _testDataProvider.CreateWorkbook(); + wb.CreateSheet("MySheet"); + + Assert.IsFalse(wb.IsSheetHidden(0)); + Assert.IsFalse(wb.IsSheetVeryHidden(0)); + Assert.AreEqual(SheetVisibility.Visible, wb.GetSheetVisibility(0)); + + wb.SetSheetVisibility(0, SheetVisibility.Hidden); + Assert.IsTrue(wb.IsSheetHidden(0)); + Assert.IsFalse(wb.IsSheetVeryHidden(0)); + Assert.AreEqual(SheetVisibility.Hidden, wb.GetSheetVisibility(0)); + + wb.SetSheetVisibility(0, SheetVisibility.VeryHidden); + Assert.IsFalse(wb.IsSheetHidden(0)); + Assert.IsTrue(wb.IsSheetVeryHidden(0)); + Assert.AreEqual(SheetVisibility.VeryHidden, wb.GetSheetVisibility(0)); + + wb.SetSheetVisibility(0, SheetVisibility.Visible); + Assert.IsFalse(wb.IsSheetHidden(0)); + Assert.IsFalse(wb.IsSheetVeryHidden(0)); + Assert.AreEqual(SheetVisibility.Visible, wb.GetSheetVisibility(0)); + + wb.Close(); + } + /** * Test that we Get the right number of sheets, * with the right text on them, no matter what @@ -151,7 +180,7 @@ public void TestHideUnHideFlags() [Test] public void TestHide() { - wbU.SetSheetHidden(0,SheetState.Hidden); + wbU.SetSheetHidden(0,SheetVisibility.Hidden); Assert.IsTrue(wbU.IsSheetHidden(0)); Assert.IsFalse(wbU.IsSheetHidden(1)); IWorkbook wb2 = _testDataProvider.WriteOutAndReadBack(wbU); @@ -168,7 +197,7 @@ public void TestHide() [Test] public void TestUnHide() { - wbH.SetSheetHidden(0,SheetState.Visible); + wbH.SetSheetHidden(0,SheetVisibility.Visible); Assert.IsFalse(wbH.IsSheetHidden(0)); Assert.IsFalse(wbH.IsSheetHidden(1)); IWorkbook wb2 = _testDataProvider.WriteOutAndReadBack(wbH);