]> source.dussan.org Git - poi.git/commitdiff
get mad and throw a runtime error if users specify columns > 255
authorAndrew C. Oliver <acoliver@apache.org>
Thu, 1 Aug 2002 18:18:16 +0000 (18:18 +0000)
committerAndrew C. Oliver <acoliver@apache.org>
Thu, 1 Aug 2002 18:18:16 +0000 (18:18 +0000)
(more than Excel will allow)
PR:
Obtained from:
Submitted by:
Reviewed by:

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352821 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/usermodel/HSSFCell.java

index 9d6298300b69c9fc40a57097ded2f7c372e5c9a3..6ba0c63f755d9dbd975563556823eecd3fae26c9 100644 (file)
@@ -182,6 +182,7 @@ public class HSSFCell
     //protected HSSFCell(Workbook book, Sheet sheet, short row, short col)
     protected HSSFCell(Workbook book, Sheet sheet, int row, short col)
     {
+        checkBounds(col);
         cellNum      = col;
         this.row     = row;
         cellStyle    = null;
@@ -221,6 +222,7 @@ public class HSSFCell
     protected HSSFCell(Workbook book, Sheet sheet, int row, short col,
                        int type)
     {
+        checkBounds(col);
         cellNum      = col;
         this.row     = row;
         cellType     = type;
@@ -953,4 +955,14 @@ public class HSSFCell
     {
         return record;
     }
+    /**
+     * @throws RuntimeException if the bounds are exceeded.
+     */
+    private void checkBounds(int cellNum) {
+      if (cellNum > 255) {
+          throw new RuntimeException("You cannot have more than 255 columns "+
+                    "in a given row (IV).  Because Excel can't handle it");
+      }  
+    }
 }