diff options
author | Josh Micich <josh@apache.org> | 2009-01-16 17:31:29 +0000 |
---|---|---|
committer | Josh Micich <josh@apache.org> | 2009-01-16 17:31:29 +0000 |
commit | eb9e672cb272cf066b9fdd631b593f0f28ac66e6 (patch) | |
tree | b19baf53cc3ca430a899124aa9251c5e465d5083 /src/ooxml/java/org | |
parent | 22bf9b70e4e6b3f1b0dbdfc28e5730d1c933a948 (diff) | |
download | poi-eb9e672cb272cf066b9fdd631b593f0f28ac66e6.tar.gz poi-eb9e672cb272cf066b9fdd631b593f0f28ac66e6.zip |
Fixing bug 46551 - spelling mistakes in xSSFCell.checkBounds(). Also fixed 0/1-based index error for cell range checks in XSSF.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@735061 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org')
-rw-r--r-- | src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java | 17 | ||||
-rw-r--r-- | src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java | 17 |
2 files changed, 18 insertions, 16 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java index 0d89bfee2b..0fdfa2c69e 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java @@ -32,7 +32,6 @@ import org.apache.poi.ss.formula.FormulaType; import org.apache.poi.ss.formula.FormulaRenderer; import org.apache.poi.xssf.model.StylesTable; import org.apache.poi.xssf.model.SharedStringsTable; -import org.apache.poi.POIXMLException; import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogFactory; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell; @@ -57,10 +56,13 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType; public final class XSSFCell implements Cell { private static POILogger logger = POILogFactory.getLogger(XSSFCell.class); + private static final String FILE_FORMAT_NAME = "BIFF12"; /** * The maximum number of columns in SpreadsheetML */ - public static final int MAX_COLUMN_NUMBER = 16384; //2^14 + public static final int MAX_COLUMN_NUMBER = 16384; // 2^14 + private static final int LAST_COLUMN_NUMBER = MAX_COLUMN_NUMBER-1; + private static final String LAST_COLUMN_NAME = "XFD"; private static final String FALSE_AS_STRING = "0"; private static final String TRUE_AS_STRING = "1"; @@ -762,12 +764,11 @@ public final class XSSFCell implements Cell { /** * @throws RuntimeException if the bounds are exceeded. */ - private static void checkBounds(int cellNum) { - if (cellNum > MAX_COLUMN_NUMBER) { - throw new IllegalArgumentException("You cannot have more than "+MAX_COLUMN_NUMBER+" columns " + - "in a given row because Excel can't handle it"); - } else if (cellNum < 0) { - throw new IllegalArgumentException("You cannot reference columns with an index of less then 0."); + private static void checkBounds(int cellIndex) { + if (cellIndex < 0 || cellIndex > LAST_COLUMN_NUMBER) { + throw new IllegalArgumentException("Invalid column index (" + cellIndex + + "). Allowable column range for " + FILE_FORMAT_NAME + " is (0.." + + LAST_COLUMN_NUMBER + ") or ('A'..'" + LAST_COLUMN_NAME + "')"); } } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java index 9de3ea46cb..1011ecaf32 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java @@ -21,7 +21,6 @@ import java.util.*; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.POIXMLException; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow; @@ -30,6 +29,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow; */ public class XSSFRow implements Row, Comparable<XSSFRow> { + private static final String FILE_FORMAT_NAME = "BIFF12"; /** * The maximum number of rows in SpreadsheetML */ @@ -317,15 +317,16 @@ public class XSSFRow implements Row, Comparable<XSSFRow> { /** * Set the row number of this row. * - * @param rowNum the row number (0-based) + * @param rowIndex the row number (0-based) * @throws IllegalArgumentException if rowNum < 0 or greater than {@link #MAX_ROW_NUMBER} */ - public void setRowNum(int rowNum) { - if(rowNum < 0) throw new IllegalArgumentException("Row number must be >= 0"); - if (rowNum > MAX_ROW_NUMBER) - throw new IllegalArgumentException("You cannot have more than "+MAX_ROW_NUMBER+" rows "); - - this.row.setR(rowNum + 1); + public void setRowNum(int rowIndex) { + if (rowIndex < 0 || rowIndex >= MAX_ROW_NUMBER) { + throw new IllegalArgumentException("Invalid row index (" + rowIndex + + "). Allowable row range for " + FILE_FORMAT_NAME + + " is (0.." + (MAX_ROW_NUMBER-1) + ")"); + } + row.setR(rowIndex + 1); } /** |