Spreadsheet: Add getUsedRange() and getNonEmptyRange()
This commit is contained in:
@@ -990,16 +990,34 @@ PyObject *SheetPy::getUsedCells(PyObject *args)
|
||||
return Py::new_reference_to(pyCellList);
|
||||
}
|
||||
|
||||
PyObject *SheetPy::getUsedRange(PyObject *args)
|
||||
{
|
||||
auto usedRange = getSheetPtr()->getCells()->getUsedRange();
|
||||
Py::Tuple pyTuple(2);
|
||||
pyTuple[0] = Py::String(std::get<0>(usedRange).toString());
|
||||
pyTuple[1] = Py::String(std::get<1>(usedRange).toString());
|
||||
return Py::new_reference_to(pyTuple);
|
||||
}
|
||||
|
||||
PyObject *SheetPy::getNonEmptyCells(PyObject *args)
|
||||
{
|
||||
auto usedCells = getSheetPtr()->getCells()->getNonEmptyCells();
|
||||
auto nonEmptyCells = getSheetPtr()->getCells()->getNonEmptyCells();
|
||||
Py::List pyCellList;
|
||||
for (const auto &cell : usedCells) {
|
||||
for (const auto &cell : nonEmptyCells) {
|
||||
pyCellList.append(Py::String(cell.toString()));
|
||||
}
|
||||
return Py::new_reference_to(pyCellList);
|
||||
}
|
||||
|
||||
PyObject *SheetPy::getNonEmptyRange(PyObject *args)
|
||||
{
|
||||
auto nonEmptyRange = getSheetPtr()->getCells()->getNonEmptyRange();
|
||||
Py::Tuple pyTuple(2);
|
||||
pyTuple[0] = Py::String(std::get<0>(nonEmptyRange).toString());
|
||||
pyTuple[1] = Py::String(std::get<1>(nonEmptyRange).toString());
|
||||
return Py::new_reference_to(pyTuple);
|
||||
}
|
||||
|
||||
|
||||
// +++ custom attributes implementer ++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
Reference in New Issue
Block a user