Commit d38eee7e authored by CharlieC's avatar CharlieC
Browse files

Ignore page breaks contained in any CustomSheetViews

Resolves #1296

--HG--
branch : 2.6
parent 3a440a7be835
......@@ -73,6 +73,7 @@ COL_BREAK_TAG = '{%s}colBreaks' % SHEET_MAIN_NS
SCENARIOS_TAG = '{%s}scenarios' % SHEET_MAIN_NS
DATA_TAG = '{%s}sheetData' % SHEET_MAIN_NS
DIMENSION_TAG = '{%s}dimension' % SHEET_MAIN_NS
CUSTOM_VIEWS_TAG = '{%s}customSheetViews' % SHEET_MAIN_NS
def _cast_number(value):
......@@ -116,6 +117,7 @@ class WorkSheetParser(object):
LEGACY_TAG: self.parse_legacy,
ROW_BREAK_TAG: self.parse_row_breaks,
COL_BREAK_TAG: self.parse_col_breaks,
CUSTOM_VIEWS_TAG: self.parse_custom_views,
}
properties = {
......@@ -311,6 +313,11 @@ class WorkSheetParser(object):
self.page_breaks.append(brk)
def parse_custom_views(self, element):
# clear page_breaks to avoid duplication
self.page_breaks = []
class WorksheetReader(object):
"""
Create a parser and apply it to a workbook
......
......@@ -713,6 +713,29 @@ class TestWorksheetParser:
assert parser.legacy_drawing == "rId3"
def test_custom_views_breaks(self, WorkSheetParser):
src = b"""
<sheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<customSheetViews >
<customSheetView scale="70">
<selection activeCell="F14" sqref="F14"/>
<rowBreaks count="1" manualBreakCount="1">
<brk id="1" max="16383" man="1"/>
</rowBreaks>
<pageMargins left="0.75" right="0.75" top="1" bottom="1" header="0.5" footer="0.5"/>
<pageSetup paperSize="9" scale="50" firstPageNumber="99" orientation="landscape" useFirstPageNumber="1"/>
<headerFooter alignWithMargins="0"/>
</customSheetView>
</customSheetViews>
</sheet>
"""
parser = WorkSheetParser
parser.source = BytesIO(src)
for _ in parser.parse():
pass
assert parser.page_breaks == []
@pytest.fixture
def PrimedWorksheetReader(Workbook, datadir):
from .._reader import WorksheetReader
......
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