aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/interfaces-jdk15
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2008-10-23 18:57:28 +0000
committerYegor Kozlov <yegor@apache.org>2008-10-23 18:57:28 +0000
commit968c6493a52b58d38262894a00d1cd3bdd080efb (patch)
tree1bdae6bde826fc6131301964ecf7cbe99d11a164 /src/ooxml/interfaces-jdk15
parentc63434df63697adf242805f7a0bde52d767907d2 (diff)
downloadpoi-968c6493a52b58d38262894a00d1cd3bdd080efb.tar.gz
poi-968c6493a52b58d38262894a00d1cd3bdd080efb.zip
1. important algorithmic improvements of XSSFRow and XSSFSheet, removed LinkedList in favor of TreeMap, that allowed O(Log(N)) performance instead of O(N) when adding new rows and cells2. Revised cell value accessors in XSSFCell. Now both HSSF and XSSF handle various cell types equally. The same exceptions are thrown in case of type mismatch, same behaviour when setting nulls, etc.
3. Moved FormulaError codes out of the Cell interface into enum. Interface isn't a proper place for it 4. Finally finished javadoc on XSSFRow and XSSFCell git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@707445 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/interfaces-jdk15')
-rw-r--r--src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java48
-rwxr-xr-xsrc/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FormulaError.java140
2 files changed, 147 insertions, 41 deletions
diff --git a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java
index 15e7f1b822..b848cd4530 100644
--- a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java
+++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java
@@ -70,26 +70,6 @@ public interface Cell {
public final static int CELL_TYPE_ERROR = 5;
- public final static class CELL_ERROR_TYPE {
- private final byte type;
- private final String repr;
- private CELL_ERROR_TYPE(int type, String repr) {
- this.type = (byte)type;
- this.repr = repr;
- }
-
- public byte getType() { return type; }
- public String getStringRepr() { return repr; }
- }
- public static final CELL_ERROR_TYPE ERROR_NULL = new CELL_ERROR_TYPE(0, "#NULL!");
- public static final CELL_ERROR_TYPE ERROR_DIV0 = new CELL_ERROR_TYPE(7, "#DIV/0!");
- public static final CELL_ERROR_TYPE ERROR_VALUE = new CELL_ERROR_TYPE(15, "#VALUE!");
- public static final CELL_ERROR_TYPE ERROR_REF = new CELL_ERROR_TYPE(23, "#REF!");
- public static final CELL_ERROR_TYPE ERROR_NAME = new CELL_ERROR_TYPE(29, "#NAME?");
- public static final CELL_ERROR_TYPE ERROR_NUM = new CELL_ERROR_TYPE(36, "#NUM!");
- public static final CELL_ERROR_TYPE ERROR_NA = new CELL_ERROR_TYPE(42, "#N/A");
-
-
/**
* set the cell's number within the row (0 based)
* @param num short the cell number
@@ -239,12 +219,12 @@ public interface Cell {
byte getErrorCellValue();
/**
- * set the style for the cell. The style should be an HSSFCellStyle created/retreived from
- * the HSSFWorkbook.
+ * set the style for the cell. The style should be an CellStyle created/retreived from
+ * the Workbook.
*
* @param style reference contained in the workbook
- * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createCellStyle()
- * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getCellStyleAt(short)
+ * @see Workbook#createCellStyle()
+ * @see Workbook#getCellStyleAt(short)
*/
void setCellStyle(CellStyle style);
@@ -252,7 +232,7 @@ public interface Cell {
/**
* get the style for the cell. This is a reference to a cell style contained in the workbook
* object.
- * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getCellStyleAt(short)
+ * @see Workbook#getCellStyleAt(short)
*/
CellStyle getCellStyle();
@@ -263,20 +243,6 @@ public interface Cell {
void setAsActiveCell();
/**
- * Returns a string representation of the cell
- *
- * This method returns a simple representation,
- * anthing more complex should be in user code, with
- * knowledge of the semantics of the sheet being processed.
- *
- * Formula cells return the formula string,
- * rather than the formula result.
- * Dates are displayed in dd-MMM-yyyy format
- * Errors are displayed as #ERR&lt;errIdx&gt;
- */
- String toString();
-
- /**
* Assign a comment to this cell
*
* @param comment comment associated with this cell
@@ -295,12 +261,12 @@ public interface Cell {
*
* @return hyperlink associated with this cell or null if not found
*/
- public Hyperlink getHyperlink();
+ Hyperlink getHyperlink();
/**
* Assign a hypelrink to this cell
*
* @param link hypelrink associated with this cell
*/
- public void setHyperlink(Hyperlink link);
+ void setHyperlink(Hyperlink link);
}
diff --git a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FormulaError.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FormulaError.java
new file mode 100755
index 0000000000..d765e0f01a
--- /dev/null
+++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/FormulaError.java
@@ -0,0 +1,140 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.ss.usermodel;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Enumerates error values in SpreadsheetML formula calculations.
+ *
+ * @author Yegor Kozlov
+ */
+public enum FormulaError {
+ /**
+ * Intended to indicate when two areas are required to intersect, but do not.
+ * <p>Example:
+ * In the case of SUM(B1 C1), the space between B1 and C1 is treated as the binary
+ * intersection operator, when a comma was intended. end example]
+ * </p>
+ */
+ NULL(0x00, "#NULL!"),
+
+ /**
+ * Intended to indicate when any number, including zero, is divided by zero.
+ * Note: However, any error code divided by zero results in that error code.
+ */
+ DIV0(0x07, "#DIV/0!"),
+
+ /**
+ * Intended to indicate when an incompatible type argument is passed to a function, or
+ * an incompatible type operand is used with an operator.
+ * <p>Example:
+ * In the case of a function argument, text was expected, but a number was provided
+ * </p>
+ */
+ VALUE(0x0F, "#VALUE!"),
+
+ /**
+ * Intended to indicate when a cell reference is invalid.
+ * <p>Example:
+ * If a formula contains a reference to a cell, and then the row or column containing that cell is deleted,
+ * a #REF! error results. If a worksheet does not support 20,001 columns,
+ * OFFSET(A1,0,20000) will result in a #REF! error.
+ * </p>
+ */
+ REF(0x1D, "#REF!"),
+
+ /**
+ * Intended to indicate when what looks like a name is used, but no such name has been defined.
+ * <p>Example:
+ * XYZ/3, where XYZ is not a defined name. Total is & A10,
+ * where neither Total nor is is a defined name. Presumably, "Total is " & A10
+ * was intended. SUM(A1C10), where the range A1:C10 was intended.
+ * </p>
+ */
+ NAME(0x1D, "#NAME?"),
+
+ /**
+ * Intended to indicate when an argument to a function has a compatible type, but has a
+ * value that is outside the domain over which that function is defined. (This is known as
+ * a domain error.)
+ * <p>Example:
+ * Certain calls to ASIN, ATANH, FACT, and SQRT might result in domain errors.
+ * </p>
+ * Intended to indicate that the result of a function cannot be represented in a value of
+ * the specified type, typically due to extreme magnitude. (This is known as a range
+ * error.)
+ * <p>Example: FACT(1000) might result in a range error. </p>
+ */
+ NUM(0x24, "#NUM!"),
+
+ /**
+ * Intended to indicate when a designated value is not available.
+ * <p>Example:
+ * Some functions, such as SUMX2MY2, perform a series of operations on corresponding
+ * elements in two arrays. If those arrays do not have the same number of elements, then
+ * for some elements in the longer array, there are no corresponding elements in the
+ * shorter one; that is, one or more values in the shorter array are not available.
+ * </p>
+ * This error value can be produced by calling the function NA
+ */
+ NA(0x2A, "#N/A");
+
+ private byte type;
+ private String repr;
+
+ private FormulaError(int type, String repr) {
+ this.type = (byte) type;
+ this.repr = repr;
+ }
+
+ /**
+ * @return numeric code of the error
+ */
+ public int getCode() {
+ return type;
+ }
+
+ /**
+ * @return string representation of the error
+ */
+ public String getString() {
+ return repr;
+ }
+
+ private static Map<String, FormulaError> smap = new HashMap<String, FormulaError>();
+ private static Map<Integer, FormulaError> imap = new HashMap<Integer, FormulaError>();
+ static{
+ for (FormulaError error : values()) {
+ imap.put(error.getCode(), error);
+ smap.put(error.getString(), error);
+ }
+ }
+
+ public static FormulaError forInt(int type){
+ FormulaError err = imap.get(type);
+ if(err == null) throw new IllegalArgumentException("Unknown error type: " + type);
+ return err;
+ }
+
+ public static FormulaError forString(String code){
+ FormulaError err = smap.get(code);
+ if(err == null) throw new IllegalArgumentException("Unknown error code: " + code);
+ return err;
+ }
+}