This commit is contained in:
Thomas Fussell 2016-07-18 03:20:20 +08:00
parent 026058d111
commit 36b676048f
2 changed files with 4 additions and 3 deletions

View File

@ -89,8 +89,9 @@ public:
{
xlnt::workbook wb, wb2;
auto new_sheet = wb.create_sheet(0);
new_sheet.set_title("removed");
wb.remove_sheet(new_sheet);
TS_ASSERT(std::find(wb.begin(), wb.end(), new_sheet) == wb.end());
TS_ASSERT_EQUALS(wb.get_sheet_by_name("removed"), nullptr);
TS_ASSERT_THROWS(wb.remove_sheet(wb2.get_active_sheet()), std::runtime_error);
}

View File

@ -316,8 +316,8 @@ worksheet workbook::create_sheet(std::size_t index)
if (index != d_->worksheets_.size() - 1)
{
std::swap(d_->worksheets_.back(), d_->worksheets_[index]);
d_->worksheets_.pop_back();
d_->worksheets_.insert(d_->worksheets_.begin() + index, d_->worksheets_.back());
d_->worksheets_.pop_back();
}
return worksheet(&d_->worksheets_[index]);