mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
commit
34669fde87
|
@ -86,6 +86,7 @@ public:
|
|||
// container
|
||||
cell get_cell(const cell_reference &reference);
|
||||
const cell get_cell(const cell_reference &reference) const;
|
||||
bool has_cell(const cell_reference &reference) const;
|
||||
range get_range(const std::string &reference_string);
|
||||
range get_range(const range_reference &reference);
|
||||
const range get_range(const std::string &reference_string) const;
|
||||
|
|
|
@ -22,6 +22,18 @@ public:
|
|||
TS_ASSERT_EQUALS(cell.get_reference(), "A1");
|
||||
}
|
||||
|
||||
void test_has_cell()
|
||||
{
|
||||
xlnt::worksheet ws(wb_);
|
||||
|
||||
const xlnt::worksheet& const_ws = ws;
|
||||
TS_ASSERT_EQUALS(const_ws.has_cell(xlnt::cell_reference("A", 1)), false);
|
||||
|
||||
ws.get_cell("C10").set_value("value");
|
||||
TS_ASSERT_EQUALS(const_ws.has_cell(xlnt::cell_reference("C", 9)), false);
|
||||
TS_ASSERT_EQUALS(const_ws.has_cell(xlnt::cell_reference("C", 10)), true);
|
||||
}
|
||||
|
||||
void test_worksheet_dimension()
|
||||
{
|
||||
xlnt::worksheet ws(wb_);
|
||||
|
|
|
@ -252,6 +252,19 @@ const cell worksheet::get_cell(const cell_reference &reference) const
|
|||
return cell(&d_->cell_map_.at(reference.get_row()).at(reference.get_column_index()));
|
||||
}
|
||||
|
||||
bool worksheet::has_cell(const cell_reference &reference) const
|
||||
{
|
||||
const auto row = d_->cell_map_.find(reference.get_row());
|
||||
if(row == d_->cell_map_.cend())
|
||||
return false;
|
||||
|
||||
const auto col = row->second.find(reference.get_column_index());
|
||||
if(col == row->second.cend())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool worksheet::has_row_properties(row_t row) const
|
||||
{
|
||||
return d_->row_properties_.find(row) != d_->row_properties_.end();
|
||||
|
|
Loading…
Reference in New Issue
Block a user