diff --git a/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java b/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java index 9e292929a..080384c3e 100644 --- a/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java +++ b/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java @@ -126,6 +126,12 @@ public abstract class CellRangeAddressBase { public final void setLastRow(int lastRow) { _lastRow = lastRow; } + /** + * @return the size of the range (number of cells in the area). + */ + public int getNumberOfCells() { + return (_lastRow - _firstRow + 1) * (_lastCol - _firstCol + 1); + } public final String toString() { CellReference crA = new CellReference(_firstRow, _firstCol); diff --git a/src/java/org/apache/poi/ss/util/Region.java b/src/java/org/apache/poi/ss/util/Region.java index aee3eef0a..27fc792c4 100644 --- a/src/java/org/apache/poi/ss/util/Region.java +++ b/src/java/org/apache/poi/ss/util/Region.java @@ -205,6 +205,14 @@ public class Region implements Comparable { { return compareTo(( Region ) o); } + + /** + * @return the size of the region (number of cells in the area). + */ + public int getArea() { + return (rowTo - rowFrom + 1) * (colTo - colFrom + 1); + } + /** * Convert a List of CellRange objects to an array of regions