]> source.dussan.org Git - poi.git/commitdiff
added getNumberOfCells CellRangeAddressBase etc
authorJosh Micich <josh@apache.org>
Wed, 19 Nov 2008 02:04:07 +0000 (02:04 +0000)
committerJosh Micich <josh@apache.org>
Wed, 19 Nov 2008 02:04:07 +0000 (02:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@718840 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/util/CellRangeAddressBase.java
src/java/org/apache/poi/ss/util/Region.java

index 9e292929afa62a2db604b93dcd560e8264f63194..080384c3e2451979017278dc4af05f5f9f59524a 100644 (file)
@@ -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);
index aee3eef0ace00dc6ac4553456437ccdf2689f019..27fc792c45ef95144c9621e1ca2b28b3f939f1ad 100644 (file)
@@ -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