You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/06/20 00:42:40 UTC

svn commit: r786696 - in /poi/trunk/src: documentation/content/xdocs/ java/org/apache/poi/hssf/record/formula/eval/ java/org/apache/poi/hssf/record/formula/functions/ testcases/org/apache/poi/hssf/data/

Author: josh
Date: Fri Jun 19 22:42:39 2009
New Revision: 786696

URL: http://svn.apache.org/viewvc?rev=786696&view=rev
Log:
Added implementation for ISNA()

Added:
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/IsNa.java
Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/FunctionEval.java
    poi/trunk/src/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=786696&r1=786695&r2=786696&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Jun 19 22:42:39 2009
@@ -33,6 +33,7 @@
 
     <changes>
         <release version="3.5-beta7" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="add">Added implementation for ISNA()</action>
            <action dev="POI-DEVELOPERS" type="add">46793 - fixed SimpleShape#getLineWidth to handle default line width </action>
            <action dev="POI-DEVELOPERS" type="add">47356 - removed unused private fields in HWPF BorderCode</action>
            <action dev="POI-DEVELOPERS" type="add">47355 - Improved  HWPF TableCell to expose TableCellDescriptor</action>
@@ -319,7 +320,7 @@
            <action dev="POI-DEVELOPERS" type="add">44937 - Partial support for extracting Escher images from HWPF files</action>
            <action dev="POI-DEVELOPERS" type="fix">44824 - Avoid an infinite loop when reading some HWPF pictures</action>
            <action dev="POI-DEVELOPERS" type="fix">44898 - Correctly handle short last blocks in POIFS</action>
-        </release>  
+        </release>
         <release version="3.1-beta2" date="2008-05-26">
            <action dev="POI-DEVELOPERS" type="fix">44306 - fixed reading/writing of AttrPtg(type=choose) and method toFormulaString() for CHOOSE formulas</action>
            <action dev="POI-DEVELOPERS" type="fix">24207 - added HSSFName.isDeleted() to check if the name points to cell that no longer exists</action>
@@ -523,14 +524,14 @@
 	    <action dev="POI-DEVELOPERS" type="add" context="All">Image writing support</action>
 	    <action dev="NB" type="add" context="All">HSLF - Initial PowerPoint Support. Includes: Support for text extraction across the whole file; Support for getting individual slides, and their notes, and extracting text from those; Initial support for changing (but not adding) text</action>
         </release>
- 
+
         <release version="2.5.1-FINAL" date="2004-02-29">
             <action dev="POI-DEVELOPERS" type="add" context="All">Outlining support</action>
             <action dev="POI-DEVELOPERS" type="fix" context="All">27574 - [PATCH] HSSFDateUtil.getExcelDate() is one hour off when DST changes</action>
             <action dev="POI-DEVELOPERS" type="fix" context="All">26465 - [PATCH] wrong lastrow entry</action>
             <action dev="POI-DEVELOPERS" type="fix" context="All">28203 - [PATCH] Unable to open read-write excel file including forms</action>
         </release>
- 
+
         <release version="2.5-FINAL" date="2004-02-29">
             <action dev="POI-DEVELOPERS" type="add" context="All">Add support for the Escher file format</action>
             <action dev="POI-DEVELOPERS" type="fix" context="All">27005 java.lang.IndexOutOfBoundsException during Workbook.cloneSheet()</action>
@@ -539,7 +540,7 @@
         <release version="2.0-FINAL" date="2004-01-26">
             <action dev="POI-DEVELOPERS" type="update" context="All">No changes</action>
         </release>
-        
+
         <release version="2.0-RC2" date="2004-01-11">
             <action dev="POI-DEVELOPERS" type="fix" context="All">Bug 25695 - HSSFCell.getStringCellValue() on cell which has string formula will return swap bye unicode characters.</action>
             <action dev="POI-DEVELOPERS" type="fix" context="All">Updated website for upcoming release</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/FunctionEval.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/FunctionEval.java?rev=786696&r1=786695&r2=786696&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/FunctionEval.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/FunctionEval.java Fri Jun 19 22:42:39 2009
@@ -26,7 +26,6 @@
 
 /**
  * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
- *  
  */
 public abstract class FunctionEval implements OperationEval {
 	/**
@@ -79,6 +78,7 @@
 
 		retval[0] = new Count();
 		retval[1] = new If();
+		retval[2] = new IsNa();
 
 		retval[3] = new IsError();
 		retval[ID.SUM] = AggregateFunction.SUM;

Added: poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/IsNa.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/IsNa.java?rev=786696&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/IsNa.java (added)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/IsNa.java Fri Jun 19 22:42:39 2009
@@ -0,0 +1,56 @@
+/* ====================================================================
+   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.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BoolEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.EvaluationException;
+import org.apache.poi.hssf.record.formula.eval.OperandResolver;
+import org.apache.poi.ss.usermodel.ErrorConstants;
+
+/**
+ * Implementation for Excel ISNA() function.<p/>
+ *
+ * <b>Syntax</b>:<br/>
+ * <b>ISNA</b>(<b>value</b>)<p/>
+ *
+ * <b>value</b>  The value to be tested<br/>
+ * <br/>
+ * Returns <tt>TRUE</tt> if the specified value is '#N/A', <tt>FALSE</tt> otherwise.
+ *
+ * @author Josh Micich
+ */
+public final class IsNa implements Function {
+
+	public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+		if(args.length != 1) {
+			return ErrorEval.VALUE_INVALID;
+		}
+		Eval arg = args[0];
+
+		try {
+			OperandResolver.getSingleValue(arg, srcCellRow, srcCellCol);
+		} catch (EvaluationException e) {
+			if (e.getErrorEval().getErrorCode() == ErrorConstants.ERROR_NA) {
+				return BoolEval.TRUE;
+			}
+		}
+		return BoolEval.FALSE;
+	}
+}

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls?rev=786696&r1=786695&r2=786696&view=diff
==============================================================================
Binary files - no diff available.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org