Commit 31e90405 authored by CharlieC's avatar CharlieC
Browse files

Merged in realrunner/openpyxl/read_only_hidden (pull request #370)

Read only hidden sheet support

--HG--
branch : 3.0
......@@ -26,4 +26,4 @@ Scripts/
downloads/
Compliance
Spec
doc/api
\ No newline at end of file
doc/api
......@@ -217,6 +217,7 @@ class ExcelReader:
if self.read_only:
ws = ReadOnlyWorksheet(self.wb, sheet.name, rel.target, self.shared_strings)
ws.sheet_state = sheet.state
self.wb._sheets.append(ws)
continue
else:
......
......@@ -196,8 +196,7 @@ class TestExcelReader:
reader.read_workbook()
assert reader.wb is not None
def test_read_workbook(self, datadir):
def test_read_workbook_theme(self, datadir):
datadir.chdir()
reader = ExcelReader("complex-styles.xlsx")
reader.read_manifest()
......@@ -205,6 +204,17 @@ class TestExcelReader:
reader.read_theme()
assert reader.wb.loaded_theme is not None
@pytest.mark.parametrize("read_only", [False, True])
def test_read_workbook_hidden(self, datadir, read_only):
datadir.chdir()
reader = ExcelReader("hidden_sheets.xlsx", read_only=read_only)
reader.read()
assert reader.wb.sheetnames == ["Sheet", "Hidden", "VeryHidden"]
hidden = reader.wb.worksheets[1]
assert hidden.sheet_state == "hidden"
very_hidden = reader.wb.worksheets[2]
assert very_hidden.sheet_state == "veryHidden"
def test_read_chartsheet(self, datadir):
datadir.chdir()
......
......@@ -34,6 +34,7 @@ class ReadOnlyWorksheet(object):
def __init__(self, parent_workbook, title, worksheet_path, shared_strings):
self.parent = parent_workbook
self.title = title
self.sheet_state = 'visible'
self._current_row = None
self._worksheet_path = worksheet_path
self._shared_strings = shared_strings
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment