Skip to content

Commit

Permalink
Merge pull request #451 from amiremohamadi/fix-cell-reference-parsing
Browse files Browse the repository at this point in the history
fix cell reference parsing
  • Loading branch information
tfussell committed Mar 20, 2020
2 parents ae6f9d2 + 3af9567 commit 6c52e52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions source/cell/cell_reference.cpp
Expand Up @@ -174,13 +174,13 @@ std::pair<std::string, row_t> cell_reference::split_reference(

if (column_string[0] == '$')
{
absolute_row = true;
absolute_column = true;
column_string = column_string.substr(1);
}

if (row_string[0] == '$')
{
absolute_column = true;
absolute_row = true;
row_string = row_string.substr(1);
}

Expand Down
12 changes: 10 additions & 2 deletions tests/cell/cell_test_suite.cpp
Expand Up @@ -665,8 +665,16 @@ class cell_test_suite : public test_suite
xlnt_assert_throws(xlnt::cell_reference("A"), xlnt::invalid_cell_reference);

auto ref = xlnt::cell_reference("$B$7");
xlnt_assert(ref.row_absolute());
xlnt_assert(ref.column_absolute());
xlnt_assert_equals(ref.row_absolute(), true);
xlnt_assert_equals(ref.column_absolute(), true);

ref = xlnt::cell_reference("$B7");
xlnt_assert_equals(ref.row_absolute(), false);
xlnt_assert_equals(ref.column_absolute(), true);

ref = xlnt::cell_reference("B$7");
xlnt_assert_equals(ref.row_absolute(), true);
xlnt_assert_equals(ref.column_absolute(), false);

xlnt_assert(xlnt::cell_reference("A1") == "A1");
xlnt_assert(xlnt::cell_reference("A1") != "A2");
Expand Down

0 comments on commit 6c52e52

Please sign in to comment.