Commit 634049fe authored by CharlieC's avatar CharlieC
Browse files

Add support for row numbers with exponents.

Resolves #1577

--HG--
branch : 3.0
parent d310b125fc14
......@@ -261,7 +261,14 @@ class WorkSheetParser(object):
attrs = dict(row.attrib)
if "r" in attrs:
try:
self.row_counter = int(attrs['r'])
except ValueError:
val = float(attrs['r'])
if val.is_integer():
self.row_counter = int(val)
else:
raise ValueError(f"{attrs['r']} is not a valid row number")
else:
self.row_counter += 1
self.col_counter = 0
......
......@@ -172,6 +172,22 @@ class TestWorksheetParser:
assert rd == {'r': '23', 's': '28', 'spans': '1:8'}
def test_read_row_with_exponent(self, WorkSheetParser):
parser = WorkSheetParser
src = """<row r="1.048573e6" spans="1:8" /> """
element = fromstring(src)
parser.parse_row(element)
assert parser.row_counter == 1048573
def test_invalid_row_number(self, WorkSheetParser):
parser = WorkSheetParser
src = """<row r="1.5" spans="1:8" /> """
element = fromstring(src)
with pytest.raises(ValueError):
parser.parse_row(element)
def test_sheet_protection(self, datadir, WorkSheetParser):
parser = WorkSheetParser
......
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