Add range worksheet::rows(int row_offset, int column_offset) const.

This commit is contained in:
Xpol Wan 2016-05-26 10:55:50 +08:00
parent 4e9c48eba9
commit 9f1edce3bc
2 changed files with 36 additions and 0 deletions

View File

@ -152,6 +152,36 @@ public:
expected_row_iter++;
}
}
void test_iter_rows_offset_int_int()
{
xlnt::workbook wb;
xlnt::worksheet ws(wb);
auto rows = ws.rows(1, 3);
const std::vector<std::vector<std::string>> expected =
{
{ "D2", "E2", "F2" },
{ "D3", "E3", "F3" },
{ "D4", "E4", "F4" },
{ "D5", "E5", "F5" }
};
auto expected_row_iter = expected.begin();
for (auto row : rows)
{
auto expected_cell_iter = (*expected_row_iter).begin();
for (auto cell : row)
{
TS_ASSERT_EQUALS(cell.get_reference(), *expected_cell_iter);
expected_cell_iter++;
}
expected_row_iter++;
}
}
void test_get_named_range()
{

View File

@ -626,6 +626,12 @@ xlnt::range worksheet::rows(const std::string &range_string, int row_offset, int
return get_range(reference.make_offset(column_offset, row_offset));
}
xlnt::range worksheet::rows(int row_offset, int column_offset) const
{
range_reference reference(calculate_dimension());
return get_range(reference.make_offset(column_offset, row_offset));
}
xlnt::range worksheet::columns() const
{
return range(*this, calculate_dimension(), major_order::column);