Commit 30adda2b authored by CharlieC's avatar CharlieC
Browse files

Set the current row of the worksheet to the highest cell in it.

Resolves #1345

--HG--
branch : 3.0
parent 8a40efa67af7
......@@ -337,7 +337,8 @@ class WorksheetReader(object):
c.data_type = cell['data_type']
self.ws._cells[(cell['row'], cell['column'])] = c
self.ws.formula_attributes = self.parser.array_formulae
self.ws._current_row = self.parser.row_counter
if self.ws._cells:
self.ws._current_row = self.ws.max_row # use cells not row dimensions
def bind_formatting(self):
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<sheetPr filterMode="false">
<pageSetUpPr fitToPage="false"/>
</sheetPr>
<dimension ref="A1:R1048576"/>
<sheetViews>
<sheetView showFormulas="false" showGridLines="true" showRowColHeaders="true" showZeros="true" rightToLeft="false" tabSelected="false" showOutlineSymbols="true" defaultGridColor="true" view="normal" topLeftCell="A1" colorId="64" zoomScale="85" zoomScaleNormal="85" zoomScalePageLayoutView="100" workbookViewId="0">
<selection pane="topLeft" activeCell="A4" activeCellId="0" sqref="A4"/>
</sheetView>
</sheetViews>
<sheetFormatPr defaultRowHeight="15" zeroHeight="false" outlineLevelRow="0" outlineLevelCol="0"/>
<cols>
<col collapsed="false" customWidth="true" hidden="false" outlineLevel="0" max="1025" min="1" style="0" width="14.43"/>
</cols>
<sheetData>
<row r="1" >
<c r="A1" s="6">
<v>85</v>
</c>
<c r="B1" s="6"/>
</row>
<row r="2" >
<c r="A2" s="7">
<v>3</v>
</c>
</row>
<row r="3" >
<c r="B3" s="7" t="n">
<v>2</v>
</c>
<c r="C3" s="7" t="n">
<v>3</v>
</c>
<c r="D3" s="7" t="n">
<v>4</v>
</c>
<c r="R3" s="7" t="n">
<v>18</v>
</c>
</row>
<row r="1048576" customFormat="false" ht="12.8" hidden="false" customHeight="true" outlineLevel="0" collapsed="false"/>
</sheetData>
</worksheet>
......@@ -750,11 +750,16 @@ class TestWorksheetParser:
@pytest.fixture
def PrimedWorksheetReader(Workbook, datadir):
def WorksheetReader():
from .._reader import WorksheetReader
datadir.chdir()
return WorksheetReader
@pytest.fixture
def PrimedWorksheetReader(Workbook, WorksheetReader, datadir):
wb = Workbook
ws = wb.create_sheet("Sheet")
datadir.chdir()
src = "complex-styles-worksheet.xml"
reader = WorksheetReader(ws, src, wb.shared_strings, data_only=False)
return reader
......@@ -890,3 +895,11 @@ class TestWorksheetReader:
for k in ('page_margins', 'page_setup', 'views', 'sheet_format',
'legacy_drawing'):
assert getattr(ws, k) == getattr(reader.parser, k)
def test_more_rows_than_cells(self, Workbook, WorksheetReader, datadir):
ws = Workbook.create_sheet("Sheet")
datadir.chdir()
reader = WorksheetReader(ws, "more_rows_than_cells.xml", None, None)
reader.bind_cells()
assert ws._current_row == 3
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