Spreadsheet: add new API PropertySheet::getNonEmptyCells()

To exclude cells without any text content. Used when printing (among
other cases) to skip empty cells.
This commit is contained in:
Zheng, Lei
2022-05-06 11:07:28 +08:00
committed by Chris Hennes
parent 1aef8e0246
commit 5f17d5edca
4 changed files with 27 additions and 15 deletions

View File

@@ -274,8 +274,8 @@ bool Sheet::exportToFile(const std::string &filename, char delimiter, char quote
if (!file.is_open())
return false;
std::set<CellAddress> usedCells = cells.getUsedCells();
std::set<CellAddress>::const_iterator i = usedCells.begin();
auto usedCells = cells.getNonEmptyCells();
auto i = usedCells.begin();
while (i != usedCells.end()) {
Property * prop = getProperty(*i);
@@ -1184,12 +1184,8 @@ int Sheet::getRowHeight(int row) const
std::vector<std::string> Sheet::getUsedCells() const
{
std::vector<std::string> usedCells;
// Insert int usedSet
std::set<CellAddress> usedSet = cells.getUsedCells();
for (std::set<CellAddress>::const_iterator i = usedSet.begin(); i != usedSet.end(); ++i)
usedCells.push_back(i->toString());
for (const auto &addr : cells.getUsedCells())
usedCells.push_back(addr.toString());
return usedCells;
}