poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1072119 [1/2] - in /poi/branches/excelant: ./ maven/ src/documentation/content/xdocs/spreadsheet/ src/excelant/ src/excelant/java/ src/excelant/java/org/ src/excelant/java/org/apache/ src/excelant/java/org/apache/poi/ src/excelant/java/org...
Date Fri, 18 Feb 2011 20:04:52 GMT
Author: yegor
Date: Fri Feb 18 20:04:50 2011
New Revision: 1072119

URL: http://svn.apache.org/viewvc?rev=1072119&view=rev
Log:
initial import of ExcelAnt tasks, see Bugzilla 50610

Added:
    poi/branches/excelant/maven/poi-excelant.pom   (with props)
    poi/branches/excelant/src/documentation/content/xdocs/spreadsheet/excelant.xml   (with props)
    poi/branches/excelant/src/excelant/
    poi/branches/excelant/src/excelant/java/
    poi/branches/excelant/src/excelant/java/org/
    poi/branches/excelant/src/excelant/java/org/apache/
    poi/branches/excelant/src/excelant/java/org/apache/poi/
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java   (with props)
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntHandlerTask.java   (with props)
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntPrecision.java   (with props)
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSet.java   (with props)
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetDoubleCell.java   (with props)
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetFormulaCell.java   (with props)
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetStringCell.java   (with props)
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTask.java   (with props)
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTest.java   (with props)
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunction.java   (with props)
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/IExcelAntWorkbookHandler.java   (with props)
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/util/
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/util/ExcelAntEvaluationResult.java   (with props)
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtil.java   (with props)
    poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtilFactory.java   (with props)
    poi/branches/excelant/src/excelant/resources/
    poi/branches/excelant/src/excelant/resources/org/
    poi/branches/excelant/src/excelant/resources/org/apache/
    poi/branches/excelant/src/excelant/resources/org/apache/poi/
    poi/branches/excelant/src/excelant/resources/org/apache/poi/ss/
    poi/branches/excelant/src/excelant/resources/org/apache/poi/ss/excelant/
    poi/branches/excelant/src/excelant/resources/org/apache/poi/ss/excelant/antlib.xml   (with props)
    poi/branches/excelant/src/excelant/testcases/
    poi/branches/excelant/src/excelant/testcases/org/
    poi/branches/excelant/src/excelant/testcases/org/apache/
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/examples/
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/examples/formula/
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/examples/formula/CalculateMortgage.java   (with props)
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/examples/formula/ExcelAntUserDefinedFunctionTestHelper.java   (with props)
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/examples/formula/TestExcelAntUserDefinedFunction.java   (with props)
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/excelant/
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/excelant/BuildFileTest.java   (with props)
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/excelant/TestBuildFile.java
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/excelant/TestExcelAntPrecision.java   (with props)
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/excelant/TestExcelAntSet.java   (with props)
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/excelant/TestExcelAntSetDoubleCell.java   (with props)
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/excelant/util/
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtilTestHelper.java   (with props)
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/excelant/util/TestExcelAntEvaluationResult.java   (with props)
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java   (with props)
    poi/branches/excelant/src/excelant/testcases/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtilFactory.java   (with props)
    poi/branches/excelant/test-data/spreadsheet/excelant.xls   (with props)
    poi/branches/excelant/test-data/spreadsheet/mortgage-calculation.xls   (with props)
Modified:
    poi/branches/excelant/build.xml
    poi/branches/excelant/src/documentation/content/xdocs/spreadsheet/book.xml

Modified: poi/branches/excelant/build.xml
URL: http://svn.apache.org/viewvc/poi/branches/excelant/build.xml?rev=1072119&r1=1072118&r2=1072119&view=diff
==============================================================================
--- poi/branches/excelant/build.xml (original)
+++ poi/branches/excelant/build.xml Fri Feb 18 20:04:50 2011
@@ -109,6 +109,15 @@ under the License.
     <property name="ooxml.testokfile" location="build/ooxml-testokfile.txt"/>
     <property name="ooxml.lite.output.dir" location="build/ooxml-lite-classes"/>
 
+    <!-- Excelant: -->
+    <property name="excelant.resource.dir" value="src/excelant/resources"/>
+    <property name="excelant.src" location="src/excelant/java"/>
+    <property name="excelant.src.test" location="src/excelant/testcases"/>
+    <property name="excelant.reports.test" location="build/excelant-test-results"/>
+    <property name="excelant.output.dir" location="build/excelant-classes"/>
+    <property name="excelant.output.test.dir" location="build/excelant-test-classes"/>
+    <property name="excelant.testokfile" location="build/excelant-testokfile.txt"/>
+
     <!-- jars in the /lib directory, see the fetch-jars target-->
     <property name="main.commons-logging.jar" location="${main.lib}/commons-logging-1.1.jar"/>
     <property name="main.commons-logging.url"
@@ -117,6 +126,8 @@ under the License.
     <property name="main.log4j.url" value="${repository.m2}/maven2/log4j/log4j/1.2.13/log4j-1.2.13.jar"/>
     <property name="main.junit.jar" location="${main.lib}/junit-3.8.1.jar"/>
     <property name="main.junit.url" value="${repository.m2}/maven2/junit/junit/3.8.1/junit-3.8.1.jar"/>
+    <property name="main.ant.jar" location="${main.lib}/ant-1.8.2.jar"/>
+    <property name="main.ant.url" value="${repository.m2}/maven2/org/apache/ant/ant/1.8.2/ant-1.8.2.jar"/>
 
     <!-- jars in the lib-ooxml directory, see the fetch-ooxml-jars target-->
     <property name="ooxml.dom4j.jar" location="${ooxml.lib}/dom4j-1.6.1.jar"/>
@@ -155,9 +166,9 @@ under the License.
     </propertyset>
 
     <path id="main.classpath">
-        <fileset dir="${main.lib}">
-            <include name="*.jar"/>
-        </fileset>
+        <pathelement location="${main.commons-logging.jar}"/>
+        <pathelement location="${main.log4j.jar}"/>
+        <pathelement location="${main.junit.jar}"/>
     </path>
 
     <path id="scratchpad.classpath">
@@ -216,6 +227,18 @@ under the License.
         <pathelement location="${scratchpad.output.dir}"/>
     </path>
 
+    <path id="excelant.classpath">
+        <path refid="ooxml.classpath"/>
+        <pathelement location="${main.ant.jar}"/>
+        <pathelement location="${ooxml.output.dir}"/>
+    </path>
+    <path id="test.excelant.classpath">
+        <path refid="ooxml.classpath"/>
+        <pathelement location="${ooxml.output.dir}"/>
+        <pathelement location="${excelant.output.dir}"/>
+        <pathelement location="${excelant.output.test.dir}"/>
+        <pathelement location="${main.output.test.dir}"/>
+    </path>
 
     <!-- Prints POI's Ant usage help -->
     <target name="help" description="Prints Apache POI's Ant usage help">
@@ -248,6 +271,9 @@ under the License.
         <mkdir dir="${ooxml.output.dir}"/>
         <mkdir dir="${ooxml.output.test.dir}"/>
         <mkdir dir="${ooxml.reports.test}"/>
+        <mkdir dir="${excelant.output.dir}"/>
+        <mkdir dir="${excelant.output.test.dir}"/>
+        <mkdir dir="${excelant.reports.test}"/>
         <mkdir dir="${examples.output.dir}"/>
         <mkdir dir="${dist.dir}"/>
         <mkdir dir="${build.site}"/>
@@ -272,6 +298,7 @@ under the License.
                     <available file="${main.commons-logging.jar}"/>
                     <available file="${main.log4j.jar}"/>
                     <available file="${main.junit.jar}"/>
+                    <available file="${main.ant.jar}"/>
                 </and>
                 <isset property="disconnected"/>
             </or>
@@ -293,6 +320,10 @@ under the License.
             <param name="sourcefile" value="${main.junit.url}"/>
             <param name="destfile" value="${main.junit.jar}"/>
         </antcall>
+        <antcall target="downloadfile">
+            <param name="sourcefile" value="${main.ant.url}"/>
+            <param name="destfile" value="${main.ant.jar}"/>
+        </antcall>
     </target>
 
     <target name="check-ooxml-jars">
@@ -397,7 +428,7 @@ under the License.
     </target>
 
     <target name="compile" depends="init, compile-main,
-    compile-scratchpad, compile-examples"
+            compile-scratchpad, compile-examples, compile-excelant"
             description="Compiles the POI main classes, scratchpad and examples"/>
 
     <target name="compile-all" depends="compile,compile-ooxml-lite"/>
@@ -509,6 +540,36 @@ under the License.
         </javac>
     </target>
 
+    <target name="compile-excelant" depends="compile-main,compile-ooxml">
+        <javac target="${jdk.version.class}"
+               source="${jdk.version.source}"
+               destdir="${excelant.output.dir}"
+               srcdir="${excelant.src}"
+               debug="${compile.debug}"
+               encoding="${java.source.encoding}"
+               fork="yes"
+               includeantruntime="false">
+            <classpath refid="excelant.classpath"/>
+        </javac>
+        <javac target="${jdk.version.class}"
+               source="${jdk.version.source}"
+               destdir="${excelant.output.test.dir}"
+               srcdir="${excelant.src.test}"
+               debug="${compile.debug}"
+               encoding="${java.source.encoding}"
+               fork="yes"
+               includeantruntime="false">
+            <classpath>
+                <path refid="excelant.classpath"/>
+                <pathelement location="${excelant.output.dir}"/>
+                <pathelement path="${main.output.test.dir}"/>
+            </classpath>
+        </javac>
+        <copy todir="${excelant.output.dir}">
+            <fileset dir="${excelant.resource.dir}"/>
+        </copy>
+    </target>
+
     <target name="compile-version" depends="init"
             description="Compiles the version class">
         <!-- Generate the .java file -->
@@ -533,7 +594,7 @@ under the License.
         <delete file="${version.java}"/>
     </target>
 
-    <target name="test" depends="compile,test-main,test-scratchpad,test-ooxml"
+    <target name="test" depends="compile,test-main,test-scratchpad,test-ooxml,test-excelant"
             description="Tests main, scratchpad and ooxml"/>
     <target name="test-all" depends="test,test-ooxml-lite"/>
 
@@ -655,6 +716,37 @@ under the License.
         <ooxml-test-runner classpath="ooxml-lite.classpath"/>
     </target>
     
+    <target name="-test-excelant-check">
+        <uptodate property="excelant.test.notRequired" targetfile="${excelant.testokfile}">
+            <srcfiles dir="${excelant.src}"/>
+            <srcfiles dir="${excelant.src.test}"/>
+        </uptodate>
+    </target>
+
+    <target name="-test-excelant-write-testfile" unless="excelant.test.failed">
+        <echo file="${excelant.testokfile}" append="false" message="testok"/>
+    </target>
+
+    <target name="test-excelant" depends="compile-excelant,-test-excelant-check"
+            unless="excelant.test.notRequired">
+        <junit printsummary="yes" fork="yes" forkmode="once" haltonfailure="${halt.on.test.failure}"
+               failureproperty="excelant.test.failed">
+            <classpath refid="test.excelant.classpath"/>
+            <syspropertyset refid="junit.properties"/>
+            <jvmarg value="${poi.test.locale}"/>
+            <formatter type="plain"/>
+            <batchtest todir="${excelant.reports.test}">
+                <fileset dir="${excelant.src.test}">
+                    <include name="**/Test*.java"/>
+                </fileset>
+            </batchtest>
+        </junit>
+        <delete file="${excelant.testokfile}"/>
+        <antcall target="-test-excelant-write-testfile"/>
+    </target>
+
+
+
     <target name="-check-docs">
         <uptodate property="main.docs.notRequired" targetfile="${build.site}/index.html">
             <srcfiles dir="${build.site.src}"/>
@@ -801,6 +893,13 @@ under the License.
                 </replacetokens>
             </filterchain>
         </copy>
+        <copy file="maven/poi-excelant.pom" tofile="${dist.dir}/poi-excelant-${version.id}.pom">
+            <filterchain>
+                <replacetokens>
+                    <token key="VERSION" value="${version.id}"/>
+                </replacetokens>
+            </filterchain>
+        </copy>
         <copy file="maven/mvn-deploy.sh" todir="${dist.dir}">
             <filterchain>
                 <replacetokens>
@@ -849,6 +948,11 @@ under the License.
             <fileset dir="${ooxml.lite.output.dir}"/>
             <metainf dir="legal/"/>
         </jar>
+        <jar destfile="${dist.dir}/${jar.name}-excelant-${version.id}-${DSTAMP}.jar"
+             manifest="build/poi-manifest.mf">
+            <fileset dir="${excelant.output.dir}"/>
+            <metainf dir="legal/"/>
+        </jar>
     </target>
 
     <target name="jar-src" description="Sources for Maven">
@@ -872,6 +976,11 @@ under the License.
             <fileset dir="${examples.src}"/>
             <metainf dir="legal/"/>
         </jar>
+        <jar destfile="${dist.dir}/${jar.name}-excelant-${version.id}-sources-${DSTAMP}.jar"
+             manifest="build/poi-manifest.mf">
+            <fileset dir="${excelant.src}"/>
+            <metainf dir="legal/"/>
+        </jar>
     </target>
 
     <target name="assemble" depends="jar,jar-src">
@@ -882,6 +991,7 @@ under the License.
             <include name="${jar.name}-ooxml-${version.id}-${DSTAMP}.jar"/>
             <include name="${jar.name}-examples-${version.id}-${DSTAMP}.jar"/>
             <include name="${jar.name}-ooxml-schemas-${version.id}-${DSTAMP}.jar"/>
+            <include name="${jar.name}-excelant-${version.id}-${DSTAMP}.jar"/>
          </patternset>  
 
         <!-- patterns to exclude from source assemblies -->         
@@ -907,7 +1017,11 @@ under the License.
 
         <zip destfile="${dist.dir}/${jar.name}-bin-${version.id}-${DSTAMP}.zip">
             <zipfileset dir="legal/" prefix="${zipdir}"/>
-            <zipfileset dir="${main.lib}" prefix="${zipdir}/lib" includes="*.jar"/>
+            <zipfileset dir="${main.lib}" prefix="${zipdir}/lib">
+              <include name="commons-logging-*.jar"/>
+              <include name="junit-*.jar"/>
+              <include name="log4j-*.jar"/>
+            </zipfileset>
             <zipfileset dir="${ooxml.lib}" prefix="${zipdir}/ooxml-lib">
               <include name="dom4j-*.jar"/>
               <include name="geronimo-stax-*.jar"/>
@@ -931,7 +1045,11 @@ under the License.
                longfile="gnu"
                compression="gzip">
             <tarfileset dir="legal/" prefix="${zipdir}"/>
-            <tarfileset dir="${main.lib}" prefix="${zipdir}/lib" includes="*.jar"/>
+            <zipfileset dir="${main.lib}" prefix="${zipdir}/lib">
+              <include name="commons-logging-*.jar"/>
+              <include name="junit-*.jar"/>
+              <include name="log4j-*.jar"/>
+            </zipfileset>
             <tarfileset dir="${ooxml.lib}" prefix="${zipdir}/ooxml-lib">
               <include name="dom4j-*.jar"/>
               <include name="geronimo-stax-*.jar"/>
@@ -1000,6 +1118,7 @@ under the License.
       <m2-install artifactId="poi-ooxml"/>
       <m2-install artifactId="poi-examples"/>
       <m2-install artifactId="poi-ooxml-schemas"/>
+      <m2-install artifactId="poi-excelant"/>
     </target>
     
     <!-- Runs Apache Rat against the source code, to spot any files -->

Added: poi/branches/excelant/maven/poi-excelant.pom
URL: http://svn.apache.org/viewvc/poi/branches/excelant/maven/poi-excelant.pom?rev=1072119&view=auto
==============================================================================
--- poi/branches/excelant/maven/poi-excelant.pom (added)
+++ poi/branches/excelant/maven/poi-excelant.pom Fri Feb 18 20:04:50 2011
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+<!--
+
+   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.
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.apache.poi</groupId>
+	<artifactId>poi-excelant</artifactId>
+	<version>@VERSION@</version>
+	<packaging>jar</packaging>
+	<name>Apache POI</name>
+	<url>http://poi.apache.org/</url>
+	<description>Apache POI Excel Ant Tasks</description>
+
+  <mailingLists>
+    <mailingList>
+      <name>POI Users List</name>
+      <subscribe>user-subscribe@poi.apache.org</subscribe>
+      <unsubscribe>user-unsubscribe@poi.apache.org</unsubscribe>
+      <archive>http://mail-archives.apache.org/mod_mbox/poi-user/</archive>
+    </mailingList>
+    <mailingList>
+      <name>POI Developer List</name>
+      <subscribe>dev-subscribe@poi.apache.org</subscribe>
+      <unsubscribe>dev-unsubscribe@poi.apache.org</unsubscribe>
+      <archive>http://mail-archives.apache.org/mod_mbox/poi-dev/</archive>
+    </mailingList>
+  </mailingLists>
+
+  <licenses>
+    <license>
+      <name>The Apache Software License, Version 2.0</name>
+      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+    </license>
+  </licenses>
+
+  <organization>
+    <name>Apache Software Foundation</name>
+    <url>http://www.apache.org/</url>
+  </organization>
+
+  <dependencies>
+    <dependency>
+       <groupId>org.apache.poi</groupId>
+       <artifactId>poi</artifactId>
+       <version>@VERSION@</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.poi</groupId>
+      <artifactId>poi-ooxml</artifactId>
+      <version>@VERSION@</version>
+    </dependency>
+  </dependencies>
+</project>

Propchange: poi/branches/excelant/maven/poi-excelant.pom
------------------------------------------------------------------------------
    svn:executable = *

Modified: poi/branches/excelant/src/documentation/content/xdocs/spreadsheet/book.xml
URL: http://svn.apache.org/viewvc/poi/branches/excelant/src/documentation/content/xdocs/spreadsheet/book.xml?rev=1072119&r1=1072118&r2=1072119&view=diff
==============================================================================
--- poi/branches/excelant/src/documentation/content/xdocs/spreadsheet/book.xml (original)
+++ poi/branches/excelant/src/documentation/content/xdocs/spreadsheet/book.xml Fri Feb 18 20:04:50 2011
@@ -40,6 +40,7 @@
         <menu-item label="Pictorial Docs" href="diagrams.html"/>
         <menu-item label="Limitations" href="limitations.html"/>
         <menu-item label="User Defined Functions" href="user-defined-functions.html"/>
+        <menu-item label="ExcelAnt Tests" href="excelant.html"/>
     </menu>
 
     <menu label="Contributer's Guide">

Added: poi/branches/excelant/src/documentation/content/xdocs/spreadsheet/excelant.xml
URL: http://svn.apache.org/viewvc/poi/branches/excelant/src/documentation/content/xdocs/spreadsheet/excelant.xml?rev=1072119&view=auto
==============================================================================
--- poi/branches/excelant/src/documentation/content/xdocs/spreadsheet/excelant.xml (added)
+++ poi/branches/excelant/src/documentation/content/xdocs/spreadsheet/excelant.xml Fri Feb 18 20:04:50 2011
@@ -0,0 +1,319 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   ====================================================================
+   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.
+   ====================================================================
+-->
+<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.1//EN" "../dtd/document-v11.dtd">
+
+<document>
+    <header>
+        <title>ExcelAnt - Ant Tasks for Validating Excel Spreadsheets</title>
+        <authors>
+            <person email="jon@loquatic.com" name="Jon Svede" id="JDS"/>
+            <person email="brian.bush@nrel.gov" name="Brian Bush" id="BWB"/>
+        </authors>
+    </header>
+  <body>
+    <section><title>ExcelAnt - Ant Tasks for Validating Excel Spreadsheets</title>
+    
+    <section><title>Introduction</title>
+            <p>ExcelAnt is a set of Ant tasks that make it possible to verify or test
+            a workbook without having to write Java code.  Of course, the tasks themselves
+            are written in Java, but to use this frame work you only need to know a little 
+            bit about Ant.</p>
+            <p>This document covers the basic usage and set up of ExcelAnt.</p>
+            <p>This document will assume basic familiarity with Ant and Ant build files.</p>
+     </section>
+     <section><title>Setup</title>
+            <p>To start with, you'll need to have the POI 3.8 or higher jar files.  If you test only .xls
+workbooks then you need to have the following jars in your path:</p>
+            <ul>
+                <li>poi-excelant-$version-YYYYDDMM.jar</li>
+                <li>poi-$version-YYYYDDMM.jar</li>
+                <li>poi-ooxml-$version-YYYYDDMM.jar</li>
+            </ul>
+            <p> If you evaluate .xlsx workbooks then you need to add these: </p>
+            <ul>
+                <li>poi-ooxml-schemas-$version-YYYYDDMM.jar</li>
+                <li>xmlbeans.jar</li>
+                <li>dom4j.jar</li>
+            </ul>
+            <p>For example, if you have these jars in a lib/ dir in your project, your build.xml 
+            might look like this:</p>
+<source><![CDATA[
+<property name="lib.dir" value="lib" />
+
+<path id="excelant.path">
+    <pathelement location="${lib.dir}/poi-excelant-3.8-beta1-20101230.jar" />
+    <pathelement location="${lib.dir}/poi-3.8-beta1-20101230.jar" />
+    <pathelement location="${lib.dir}/poi-ooxml-3.8-beta1-20101230.jar" />
+</path>     
+]]></source>       
+        <p>Next, you'll need to define the Ant tasks. There are several ways to use ExcelAnt:</p>
+
+<ul><li>The traditional way:</li></ul>
+<source><![CDATA[
+    <typedef resource="org/apache/poi/ss/excelant/antlib.xml" classpathref="excelant.path" />
+]]></source>
+<p>
+ Where excelant.path referes to the classpath with POI jars.
+ Using this approach the provided extensions will live in the default namespace. Note that the default task/typenames (evaluate, test) may be too generic and should either be explicitly overridden or used with a namespace.
+</p>
+<ul><li>Similar, but assigning a namespace URI:</li></ul> 
+<source><![CDATA[
+<project name="excelant-demo"  xmlns:poi="antlib:org.apache.poi.ss.excelant">
+
+    <typedef resource="org/apache/poi/ss/excelant/antlib.xml"
+             classpathref="excelant.classpath"
+             uri="antlib:org.apache.poi.ss.excelant"/>
+
+    <target name="test-nofile">
+        <poi:excelant>
+
+        </poi:excelant>
+    </target>
+</project>
+]]></source>
+      </section>
+ 
+      <section><title>A Simple Example</title>
+     <p>The simplest example of using Excel is the ability to validate that POI is giving you back
+     the value you expect it to. Does this mean that POI is inaccurate?  Hardly.  There are cases
+     where POI is unable to evaluate cells for a variety of reasons.  If you need to write code
+     to integrate a worksheet into an app, you may want to know that it's going to work before 
+     you actually try to write that code.  ExcelAnt helps with that.</p>
+     
+     <p>Consider the mortgage-calculation.xls file found in the Examples 
+     (/examples/src/org/apache/poi/ss/examples/excelant/simple-mortgage-calculation.xls).  This sheet
+     is shown below:</p>
+     
+     <!--img src="../resources/images/simple-xls-with-function.jpg" alt="mortgage calculation spreadsheet"/-->
+     
+          <p>This sheet calculates the principal and interest payment for a mortgage based
+     on the amount of the loan, term and rate. To write a simple ExcelAnt test you 
+     need to tell ExcelAnt about the file like this:</p>
+<source><![CDATA[
+<property name="xls.file" value="" />
+     
+<target name="simpleTest">
+    <excelant fileName="${xls.file}">
+        <test name="checkValue" showFailureDetail="true">
+            <evaluate showDelta="true" cell="'MortgageCalculator'!$B$4" expectedValue="790.7936" precision="1.0e-4" />
+        </test>
+    </excelant>
+</target>   
+]]></source>
+
+     
+     <p>This code sets up ExcelAnt to access the file defined in the ant property
+     xls.file.  Then it creates a 'test' named 'checkValue'.  Finally it tries
+     to evaluate the B4 on the sheet named 'MortgageCalculator'.   There are some assumptions
+     here that are worth explaining.  For starters, ExcelAnt is focused on the testing
+     numerically oriented sheets.  The &lt;evaluate&gt; task is actually evaluating the
+     cell as a formula using a FormulaEvaluator instance from POI.  Therefore it will fail
+     if you point it to a cell that doesn't contain a formula or a test a plain old number.</p>
+     
+     <p>Having said all that, here is what the output looks like:</p>
+     
+<source><![CDATA[
+simpleTest:
+ [excelant] ExcelAnt version 0.4.0 Copyright 2011
+ [excelant] Using input file: resources/excelant.xls
+ [excelant] 1/1 tests passed.
+BUILD SUCCESSFUL
+Total time: 391 milliseconds     
+]]></source>
+
+		</section>
+		
+		<section><title>Setting Values into a Cell</title>
+     <p>So now we know that at a minimum POI can use our sheet to calculate the existing value.
+     This is an important point: in many cases sheets have dependencies, i.e., cells they reference.
+     As is often the case, these cells may have dependencies, which may have dependencies, etc.
+     The point is that sometimes a dependent cell may get adjusted by a macro or a function
+     and it may be that POI doesn't have the capabilities to do the same thing.  This test
+     verifies that we can rely on POI to retrieve the default value, based on the stored values
+     of the sheet.  Now we want to know if we can manipulate those dependencies and verify
+     the output.</p>
+     
+     <p>To verify that we can manipulate cell values, we need a way in ExcelAnt to set a value.
+     This is provided by the following task types:</p>
+     <ul>
+        <li>setDouble() - sets the specified cell as a double.</li>
+        <li>setFormula() - sets the specified cell as a formula.</li>
+        <li>setString() = sets the specified cell as a String.</li>
+     </ul>
+     
+     <p>For the purposes of this example we'll use the &lt;setDouble&gt; task.  Let's
+     start with a $240,000, 30 year loan at 11% (let's pretend it's like 1984).  Here
+     is how we will set that up:</p>
+     
+<source><![CDATA[
+<setDouble cell="'MortgageCalculator'!$B$1" value="240000"/>
+<setDouble cell="'MortgageCalculator'!$B$2" value ="0.11"/>
+<setDouble cell="'MortgageCalculator'!$B$3" value ="30"/>
+<evaluate showDelta="true" cell="'MortgageCalculator'!$B$4" expectedValue="2285.576149" precision="1.0e-4" />     
+]]></source>
+
+     <p>Don't forget that we're verifying the behavior so you need to put all this
+     into the sheet.  That is how I got the result of $2,285 and change. So save your
+     changes and run it; you should get the following: </p>
+     
+<source><![CDATA[     
+Buildfile: C:\opt\eclipse\workspaces\excelant\excelant.examples\build.xml
+simpleTest:
+ [excelant] ExcelAnt version 0.4.0 Copyright 2011
+ [excelant] Using input file: resources/excelant.xls
+ [excelant] 1/1 tests passed.
+BUILD SUCCESSFUL
+Total time: 406 milliseconds     
+]]></source>
+
+</section>
+		
+		<section><title>Getting More Details</title>
+
+      <p>This is great, it's working! However, suppose you want to see a little more detail.  The
+      ExcelAnt tasks leverage the Ant logging so you can add the -verbose and -debug flags to
+      the Ant command line to get more detail.  Try adding -verbose.  Here is what 
+      you should see:</p>
+      
+<source><![CDATA[
+simpleTest:
+ [excelant] ExcelAnt version 0.4.0 Copyright 2011
+ [excelant] Using input file: resources/excelant.xls
+ [evaluate] test precision = 1.0E-4 global precision = 0.0
+ [evaluate] Using evaluate precision of 1.0E-4
+ [excelant] 1/1 tests passed.
+BUILD SUCCESSFUL
+Total time: 406 milliseconds     
+]]></source>
+
+     
+     <p>We see a little more detail.  Notice that we see that there is a setting for global precision.
+     Up until now we've been setting the precision on each evaluate that we call.  This 
+     is obviously useful but it gets cumbersome.  It would be better if there were a way
+     that we could specify a global precision - and there is.  There is a &lt;precision&gt; 
+     tag that you can specify as a child of the &lt;excelant&gt; tag.  Let's go back to 
+     our original task we set up earlier and modify it:</p>
+     
+<source><![CDATA[
+<property name="xls.file" value="" />
+     
+<target name="simpleTest">
+    <excelant fileName="${xls.file}">
+        <precision value="1.0e-3"/>
+        <test name="checkValue" showFailureDetail="true">
+            <evaluate showDelta="true" cell="'MortgageCalculator'!$B$4" expectedValue="790.7936" />
+        </test>
+    </excelant>
+</target>   
+]]></source>
+     
+     <p>In this example we have set the global precision to 1.0e-3.  This means that
+     in the absence of something more stringent, all tests in the task will use
+     the global precision.  We can still override this by specifying the
+     precision attribute of all of our &lt;evaluate&gt; task.  Let's first run
+     this task with the global precision and the -verbose flag:</p>
+     
+<source><![CDATA[     
+simpleTest:
+[excelant] ExcelAnt version 0.4.0 Copyright 2011
+[excelant] Using input file: resources/excelant.xls
+[excelant] setting precision for the test checkValue
+    [test] setting globalPrecision to 0.0010 in the evaluator
+[evaluate] test precision = 0.0  global precision = 0.0010
+[evaluate] Using global precision of 0.0010
+[excelant] 1/1 tests passed.
+]]></source>
+
+     
+     <p>As the output clearly shows, the test itself has no precision but there is
+     the global precision.  Additionally, it tells us we're going to use that
+     more stringent global value. Now suppose that for this test we want 
+     to use a more stringent precision, say 1.0e-4.  We can do that by adding
+     the precision attribute back to the &lt;evaluate&gt; task:</p>
+
+<source><![CDATA[
+<excelant fileName="${xls.file}">
+    <precision value="1.0e-3"/>
+    <test name="checkValue" showFailureDetail="true">
+        <setDouble cell="'MortgageCalculator'!$B$1" value="240000"/>
+        <setDouble cell="'MortgageCalculator'!$B$2" value ="0.11"/>
+        <setDouble cell="'MortgageCalculator'!$B$3" value ="30"/>
+        <evaluate showDelta="true" cell="'MortgageCalculator'!$B$4" expectedValue="2285.576149" precision="1.0e-4" />
+    </test>
+</excelant>
+]]></source>
+
+
+     <p>Now when you re-run this test with the verbose flag you will see that
+     your test ran and passed with the higher precision:</p>
+<source><![CDATA[
+simpleTest:
+ [excelant] ExcelAnt version 0.4.0 Copyright 2011
+ [excelant] Using input file: resources/excelant.xls
+ [excelant] setting precision for the test checkValue
+     [test] setting globalPrecision to 0.0010 in the evaluator
+ [evaluate] test precision = 1.0E-4 global precision = 0.0010
+ [evaluate] Using evaluate precision of 1.0E-4 over the global precision of 0.0010
+ [excelant] 1/1 tests passed.
+BUILD SUCCESSFUL
+Total time: 390 milliseconds     
+]]></source>
+     </section>
+     
+     <section><title>Leveraging User Defined Functions</title>
+     <p>POI has an excellent feature (besides ExcelAnt) called <link href="user-defined-functions.html">User Defined Functions</link>,
+     that allows you to write Java code that will be used in place of custom VB
+     code or macros is a spreadsheet.  If you have read the documentation and written
+     your own FreeRefFunction implmentations, ExcelAnt can make use of this code.
+     For each &lt;excelant&gt; task you define you can nest a &lt;udf&gt; tag 
+     which allows you to specify the function alias and the class name.</p>
+     
+     <p>Consider the previous example of the mortgage calculator.  What if, instead
+     of being a formula in a cell, it was a function defined in a VB macro?  As luck
+     would have it, we already have an example of this in the examples from the 
+     User Defined Functions example, so let's use that. In the example spreadsheet
+     there is a tab for  MortgageCalculatorFunction, which will use.  If you look in
+     cell B4, you see that rather than a messy cell based formula, there is only the function
+     call.  Let's not get bogged down in the function/Java implementation, as these
+     are covered in the User Defined Function documentation.  Let's just add
+     a new target and test to our existing build file:</p> 
+<source><![CDATA[
+  <target name="functionTest">
+      <excelant fileName="${xls.file}">
+          <udf functionAlias="calculatePayment" class="org.apache.poi.ss.examples.formula.CalculateMortgage"/>
+          <precision value="1.0e-3"/>
+          <test name="checkValue" showFailureDetail="true">
+              <setDouble cell="'MortgageCalculator'!$B$1" value="240000"/>
+              <setDouble cell="'MortgageCalculator'!$B$2" value ="0.11"/>
+              <setDouble cell="'MortgageCalculator'!$B$3" value ="30"/>
+              <evaluate showDelta="true" cell="'MortgageCalculatorFunction'!$B$4" expectedValue="2285.576149" precision="1.0e-4" />
+          </test>
+       </excelant>
+    </target>
+]]></source> 
+
+     <p>So if you look at this carefully it looks the same as the previous examples.  We
+     still use the global precision, we're still setting values, and we still want
+     to evaluate a cell.  The only real differences are the sheet name and the
+     addition of the function.</p>    
+     </section>
+ </section>
+</body>
+</document>      

Propchange: poi/branches/excelant/src/documentation/content/xdocs/spreadsheet/excelant.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java
URL: http://svn.apache.org/viewvc/poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java?rev=1072119&view=auto
==============================================================================
--- poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java (added)
+++ poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java Fri Feb 18 20:04:50 2011
@@ -0,0 +1,146 @@
+/* ====================================================================
+   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.excelant;
+
+import org.apache.poi.ss.excelant.util.ExcelAntEvaluationResult;
+import org.apache.poi.ss.excelant.util.ExcelAntWorkbookUtil;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+/**
+ * Instances of this class are used to evaluate a single cell.  This is usually
+ * after some values have been set.  The evaluation is actually performed
+ * by a WorkbookUtil instance.  The evaluate() method of the WorkbookUtil
+ * class returns an EvaluationResult which encapsulates the results and 
+ * information from the evaluation.
+ * 
+ * @author Jon Svede ( jon [at] loquatic [dot] com )
+ * @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov )
+
+ *
+ */
+public class ExcelAntEvaluateCell extends Task {
+
+	private String cell ;
+	private double expectedValue ;
+	private double precision ;
+	private double precisionToUse ;
+	private double globalPrecision ;
+	private boolean requiredToPass = false ;
+	
+	
+	private ExcelAntEvaluationResult result  ;
+	
+	private ExcelAntWorkbookUtil wbUtil ;
+	
+	private boolean showDelta = false ;
+	
+	
+	public ExcelAntEvaluateCell() {}
+
+	protected void setWorkbookUtil( ExcelAntWorkbookUtil wb ) {
+		wbUtil = wb ;
+	}
+	
+	public void setShowDelta( boolean value ) {
+		showDelta = value ;
+	}
+	
+	protected boolean showDelta() {
+		return showDelta ;
+	}
+	
+	public void setCell(String cell) {
+		this.cell = cell;
+	}
+	
+	public void setRequiredToPass( boolean val ) {
+	    requiredToPass = val ;
+	}
+	
+	protected boolean requiredToPass() {
+	    return requiredToPass ;
+	}
+
+	public void setExpectedValue(double expectedValue) {
+		this.expectedValue = expectedValue;
+	}
+
+	public void setPrecision(double precision) {
+		this.precision = precision;
+	}
+	
+	protected void setGlobalPrecision( double prec ) {
+		globalPrecision = prec ;
+	}
+
+	protected String getCell() {
+		return cell;
+	}
+
+	protected double getExpectedValue() {
+		return expectedValue;
+	}
+
+	protected double getPrecision() {
+		return precisionToUse;
+	}
+	
+	public void execute() throws BuildException {
+		
+		precisionToUse = 0 ;
+		
+		// if there is a globalPrecision we will use it unless there is also
+		// precision set at the evaluate level, then we use that.  If there
+		// is not a globalPrecision, we will use the local precision.
+		log( "test precision = " + precision + "\tglobal precision = " + globalPrecision, Project.MSG_VERBOSE ) ;
+		if( globalPrecision > 0 ) {
+			if( precision > 0 ) {
+				precisionToUse = precision ;
+				log( "Using evaluate precision of " + precision + " over the " +
+						  "global precision of " + globalPrecision, Project.MSG_VERBOSE ) ;
+			} else {
+				precisionToUse = globalPrecision ;
+				log( "Using global precision of " + globalPrecision, Project.MSG_VERBOSE ) ;
+			}
+		} else {
+			precisionToUse = precision ;
+			log( "Using evaluate precision of " + precision, Project.MSG_VERBOSE ) ;
+		}
+		result = wbUtil.evaluateCell(cell, expectedValue, precisionToUse ) ;
+		
+		StringBuffer sb = new StringBuffer() ;
+		sb.append( "evaluation of cell " ) ;
+		sb.append( cell ) ; 
+		sb.append( " resulted in " ) ;
+		sb.append( result.getReturnValue() ) ;
+		if( showDelta == true ) {
+			sb.append( " with a delta of " + result.getDelta() ) ;
+		}
+		
+		log( sb.toString(), Project.MSG_DEBUG) ;
+
+	}
+	
+	public ExcelAntEvaluationResult getResult() {
+		return result ;
+	}
+	
+	
+}

Propchange: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntHandlerTask.java
URL: http://svn.apache.org/viewvc/poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntHandlerTask.java?rev=1072119&view=auto
==============================================================================
--- poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntHandlerTask.java (added)
+++ poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntHandlerTask.java Fri Feb 18 20:04:50 2011
@@ -0,0 +1,60 @@
+/* ====================================================================
+   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.excelant;
+
+import org.apache.poi.ss.excelant.util.ExcelAntWorkbookUtil;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+/**
+ * This is the class that backs the <handler> tag in the Ant task.
+ * 
+ * @author Jon Svede ( jon [at] loquatic [dot] com )
+ * @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov )
+ *
+ */
+public class ExcelAntHandlerTask extends Task {
+    
+    private String className ;
+    
+    private ExcelAntWorkbookUtil wbUtil ;
+
+    public void setClassName( String cName ) {
+        className = cName ;
+    }
+    
+    protected void setEAWorkbookUtil( ExcelAntWorkbookUtil wkbkUtil ) {
+        wbUtil = wkbkUtil ;
+    }
+    
+    public void execute() throws BuildException {
+        log( "handling the workbook with class " + className, Project.MSG_INFO ) ;
+        try {
+            Class clazz = Class.forName( className ) ;
+            Object handlerObj = clazz.newInstance() ;
+            if( handlerObj instanceof IExcelAntWorkbookHandler ) {
+                IExcelAntWorkbookHandler iHandler = (IExcelAntWorkbookHandler)handlerObj ;
+                iHandler.setWorkbook( wbUtil.getWorkbook() ) ;
+                iHandler.execute() ;
+             }
+        } catch( Exception e ) {
+            throw new BuildException( e.getMessage(), e ) ;
+        }
+    }
+ }

Propchange: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntHandlerTask.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntPrecision.java
URL: http://svn.apache.org/viewvc/poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntPrecision.java?rev=1072119&view=auto
==============================================================================
--- poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntPrecision.java (added)
+++ poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntPrecision.java Fri Feb 18 20:04:50 2011
@@ -0,0 +1,39 @@
+/* ====================================================================
+   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.excelant;
+
+import org.apache.tools.ant.taskdefs.Typedef;
+
+/**
+ * 
+ * @author Jon Svede ( jon [at] loquatic [dot] com )
+ * @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov )
+ * 
+ */
+public class ExcelAntPrecision extends Typedef {
+	
+	private double value ;
+	
+	public void setValue( double precision ) {
+		value = precision ;
+	}
+	
+	public double getValue() {
+		return value ;
+	}
+}

Propchange: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntPrecision.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSet.java
URL: http://svn.apache.org/viewvc/poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSet.java?rev=1072119&view=auto
==============================================================================
--- poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSet.java (added)
+++ poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSet.java Fri Feb 18 20:04:50 2011
@@ -0,0 +1,48 @@
+/* ====================================================================
+   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.excelant;
+
+import org.apache.poi.ss.excelant.util.ExcelAntWorkbookUtil;
+import org.apache.tools.ant.Task;
+
+/**
+ * 
+ * @author Jon Svede ( jon [at] loquatic [dot] com )
+ * @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov )
+ * 
+ */
+public abstract class ExcelAntSet extends Task {
+    
+    protected String cellStr ;
+    
+    protected ExcelAntWorkbookUtil wbUtil ;
+    
+    public void setCell( String cellName ) {
+        cellStr = cellName ;
+    }
+    
+    public String getCell() {
+        return cellStr ;
+    }
+    
+    
+    public void setWorkbookUtil( ExcelAntWorkbookUtil wb ) {
+        wbUtil = wb ;
+    }
+
+}

Propchange: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSet.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetDoubleCell.java
URL: http://svn.apache.org/viewvc/poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetDoubleCell.java?rev=1072119&view=auto
==============================================================================
--- poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetDoubleCell.java (added)
+++ poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetDoubleCell.java Fri Feb 18 20:04:50 2011
@@ -0,0 +1,60 @@
+/* ====================================================================
+   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.excelant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * Class for use in an Ant build script that sets the value of an Excel
+ * sheet cell using the cell id ('Sheet Name'!cellId).
+ * 
+ * @author Jon Svede ( jon [at] loquatic [dot] com )
+ * @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov )
+ * 
+ */
+public class ExcelAntSetDoubleCell extends ExcelAntSet {
+	
+	
+	private double cellValue ;
+	
+	public ExcelAntSetDoubleCell() {}
+	
+	/**
+	 * Set the value of the specified cell as the double passed in.
+	 * @param value
+	 */
+	public void setValue( double value ) {
+		cellValue = value ;
+	}
+
+	/**
+	 * Return the cell value as a double.
+	 * @return
+	 */
+	public double getCellValue() {
+		return cellValue;
+	}
+	
+	public void execute() throws BuildException {
+
+		wbUtil.setDoubleValue(cellStr, cellValue ) ;
+		
+		log( "set cell " + cellStr + " to value " + cellValue + " as double.", Project.MSG_DEBUG ) ;
+	}
+}

Propchange: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetDoubleCell.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetFormulaCell.java
URL: http://svn.apache.org/viewvc/poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetFormulaCell.java?rev=1072119&view=auto
==============================================================================
--- poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetFormulaCell.java (added)
+++ poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetFormulaCell.java Fri Feb 18 20:04:50 2011
@@ -0,0 +1,52 @@
+/* ====================================================================
+   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.excelant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * Class for use in an Ant build script that sets the formula of an Excel
+ * sheet cell using the cell id ('Sheet Name'!cellId).
+ * 
+ * @author Jon Svede ( jon [at] loquatic [dot] com )
+ * @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov )
+ *
+ */
+public class ExcelAntSetFormulaCell extends ExcelAntSet {
+	
+	
+	private String cellValue ;
+	
+	public ExcelAntSetFormulaCell() {}
+	
+	public void setValue( String value ) {
+		cellValue = value ;
+	}
+
+	protected String getCellValue() {
+		return cellValue;
+	}
+	
+	public void execute() throws BuildException {
+		
+		wbUtil.setFormulaValue( cellStr, cellValue ) ;
+		
+		log( "set cell " + cellStr + " to formula " + cellValue, Project.MSG_DEBUG ) ;
+	}
+}

Propchange: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetFormulaCell.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetStringCell.java
URL: http://svn.apache.org/viewvc/poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetStringCell.java?rev=1072119&view=auto
==============================================================================
--- poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetStringCell.java (added)
+++ poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetStringCell.java Fri Feb 18 20:04:50 2011
@@ -0,0 +1,62 @@
+/* ====================================================================
+   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.excelant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * Class for use in an Ant build script that sets the value of an Excel
+ * sheet cell using the cell id ('Sheet Name'!cellId).
+ * 
+ * @author Jon Svede ( jon [at] loquatic [dot] com )
+ * @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov )
+ *
+ */
+public class ExcelAntSetStringCell extends ExcelAntSet {
+	
+	
+	private String stringValue ;
+	
+	
+	public ExcelAntSetStringCell() {}
+
+	
+	/**
+	 * Set the value of the cell to the String passed in.
+	 * @param value
+	 */
+	public void setValue(String value ) {
+		stringValue = value ;
+	}
+
+	/**
+	 * Return the value that will be set into the cell.
+	 * @return
+	 */
+	public String getCellValue() {
+		return stringValue;
+	}
+	
+	public void execute() throws BuildException {
+
+		wbUtil.setStringValue(cellStr, stringValue ) ;
+		
+		log( "set cell " + cellStr + " to value " + stringValue + " as String.", Project.MSG_DEBUG ) ;
+	}
+}

Propchange: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntSetStringCell.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTask.java
URL: http://svn.apache.org/viewvc/poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTask.java?rev=1072119&view=auto
==============================================================================
--- poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTask.java (added)
+++ poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTask.java Fri Feb 18 20:04:50 2011
@@ -0,0 +1,193 @@
+/* ====================================================================
+   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.excelant;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import org.apache.poi.ss.excelant.util.ExcelAntWorkbookUtil;
+import org.apache.poi.ss.excelant.util.ExcelAntWorkbookUtilFactory;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+/**
+ * Ant task class for testing Excel workbook cells.
+ * 
+ * @author Jon Svede ( jon [at] loquatic [dot] com )
+ * @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov )
+ *
+ */
+public class ExcelAntTask extends Task {
+    
+    public static final String VERSION = "0.5.0" ;
+	
+	private String excelFileName ;
+	
+	private boolean failOnError = false  ;
+	
+	private ExcelAntWorkbookUtil workbookUtil ;
+	
+	private ExcelAntPrecision precision ;
+	
+	private LinkedList<ExcelAntTest> tests ;
+	private LinkedList<ExcelAntUserDefinedFunction> functions ;
+	
+	public ExcelAntTask() {
+		tests = new LinkedList<ExcelAntTest>() ;
+		functions = new LinkedList<ExcelAntUserDefinedFunction>() ;
+	}
+
+	public void addPrecision( ExcelAntPrecision prec ) {
+		precision = prec ;
+	}
+	
+	public void setFailOnError( boolean value ) {
+		failOnError = value ;
+	}
+	public void setFileName( String fileName ) {
+		excelFileName = fileName ;
+	}
+	
+	public void addTest( ExcelAntTest testElement ) {
+		tests.add( testElement ) ;
+	}
+	
+	public void addUdf( ExcelAntUserDefinedFunction def ) {
+		functions.add( def ) ;
+	}
+	
+	public void execute() throws BuildException {
+        checkClassPath();
+
+		int totalCount = 0 ;
+		int successCount = 0 ;
+		
+		StringBuffer versionBffr = new StringBuffer() ;
+		versionBffr.append(  "ExcelAnt version " ) ;
+		versionBffr.append( VERSION ) ;
+		versionBffr.append( " Copyright 2011" ) ;
+		SimpleDateFormat sdf = new SimpleDateFormat( "yyyy" ) ;
+		double currYear = Double.parseDouble( sdf.format( new Date() ) );
+		if( currYear > 2011 ) {
+		    versionBffr.append( "-" ) ;
+		    versionBffr.append( currYear ) ;
+		}
+		log( versionBffr.toString(), Project.MSG_INFO ) ;
+		
+		log( "Using input file: " + excelFileName, Project.MSG_INFO ) ;
+		
+		Workbook targetWorkbook = loadWorkbook() ;
+		if( targetWorkbook == null ) {
+			log( "Unable to load " + excelFileName + 
+					            ".  Verify the file exists and can be read.",
+					            Project.MSG_ERR ) ;
+			return ;
+		}
+		if( tests != null && tests.size() > 0 ) {
+			
+			Iterator<ExcelAntTest> testsIt = tests.iterator() ;
+			while( testsIt.hasNext() ) {
+				ExcelAntTest test = testsIt.next();
+				
+				log( "executing test: " + test.getName(), Project.MSG_DEBUG ) ;
+		
+				workbookUtil = ExcelAntWorkbookUtilFactory.getInstance( excelFileName ) ;
+				
+				if( functions != null ) {
+					Iterator<ExcelAntUserDefinedFunction> functionsIt = functions.iterator() ;
+					while( functionsIt.hasNext() ) {
+						ExcelAntUserDefinedFunction eaUdf = functionsIt.next() ;
+						try {
+							workbookUtil.addFunction(eaUdf.getFunctionAlias(), eaUdf.getClassName() ) ;
+						} catch ( Exception e) {
+							throw new BuildException( e.getMessage(), e ); 
+ 						}
+					}
+				}
+				test.setWorkbookUtil( workbookUtil ) ;
+				
+				if( precision != null && precision.getValue() > 0 ) {
+					log( "setting precision for the test " + test.getName(), Project.MSG_VERBOSE ) ; 
+					test.setPrecision( precision.getValue() ) ;
+				}
+				
+				test.execute() ;
+				
+				if( test.didTestPass() ) {
+					successCount++ ;
+				} else {
+					if( failOnError == true ) {
+						throw new BuildException( "Test " + test.getName() + " failed." ) ;
+					}
+				}
+				totalCount++ ;
+				
+				workbookUtil = null ;
+			}
+			log( successCount + "/" + totalCount + " tests passed.", Project.MSG_INFO ) ;
+			workbookUtil = null ;
+		}
+	}
+	
+
+    private Workbook loadWorkbook() {
+        if (excelFileName == null) {
+            throw new BuildException("fileName attribute must be set!",
+                                     getLocation());
+        }
+
+		Workbook workbook;
+		File workbookFile = new File( excelFileName ) ;
+        try {
+            FileInputStream fis = new FileInputStream( workbookFile ) ;
+            workbook = WorkbookFactory.create( fis ) ;
+        } catch (Exception e) {
+            throw new BuildException("Cannot load file " + excelFileName
+                    + ". Make sure the path and file permissions are correct.", e, getLocation());
+        }
+		return workbook ;
+	}
+
+
+    /**
+     * ExcelAnt depends on external libraries not included in the Ant distribution.
+     * Give user a sensible message if any if the required jars are missing.
+     */
+    private void checkClassPath(){
+        try {
+            Class.forName("org.apache.poi.hssf.usermodel.HSSFWorkbook");
+            Class.forName("org.apache.poi.ss.usermodel.WorkbookFactory");
+        } catch (Throwable e) {
+            throw new BuildException(
+                    "The <classpath> for <excelant> must include poi.jar and poi-ooxml.jar " +
+                    "if not in Ant's own classpath. Processing .xlsx spreadsheets requires " +
+                    "additional poi-ooxml-schemas.jar, xmlbeans.jar and dom4j.jar" ,
+                    e, getLocation());
+        }
+
+    }
+}

Propchange: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTask.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTest.java
URL: http://svn.apache.org/viewvc/poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTest.java?rev=1072119&view=auto
==============================================================================
--- poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTest.java (added)
+++ poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTest.java Fri Feb 18 20:04:50 2011
@@ -0,0 +1,224 @@
+/* ====================================================================
+   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.excelant;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import org.apache.poi.ss.excelant.util.ExcelAntEvaluationResult;
+import org.apache.poi.ss.excelant.util.ExcelAntWorkbookUtil;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+/**
+ * This class represents a single test.  In order for the test any and all
+ * ExcelAntEvaluateCell evaluations must pass.  Therefore it is recommended
+ * that you use only 1 evaluator but you can use more if you choose.
+ * 
+ * @author Jon Svede ( jon [at] loquatic [dot] com )
+ * @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov )
+ *
+ */
+public class ExcelAntTest extends Task{
+	
+	private LinkedList<ExcelAntSet> setters ;
+	private LinkedList<ExcelAntEvaluateCell>evaluators ;
+	
+	private LinkedList<Task> testTasks ;
+	
+	private String name ;
+	
+	private double globalPrecision ;
+	
+	private boolean showSuccessDetails = false ;
+	
+	private boolean showFailureDetail = false ;
+	LinkedList<String> failureMessages ;
+	
+
+	private ExcelAntWorkbookUtil workbookUtil ;
+	
+	private boolean passed = true ;
+
+	
+	public ExcelAntTest() {
+		setters = new LinkedList<ExcelAntSet>() ;
+		evaluators = new LinkedList<ExcelAntEvaluateCell>() ;
+		failureMessages = new LinkedList<String>() ;
+		testTasks = new LinkedList<Task>() ;
+	}
+	
+	public void setPrecision( double precision ) {
+		globalPrecision = precision ;
+	}
+	
+	public void setWorkbookUtil( ExcelAntWorkbookUtil wbUtil ) {
+		workbookUtil = wbUtil ;
+	}
+	
+	
+	public void setShowFailureDetail( boolean value ) {
+		showFailureDetail = value ;
+	}
+	
+	public void setName( String nm ) {
+		name = nm ;
+	}
+	
+	public String getName() {
+		return name ;
+	}
+	
+	public void setShowSuccessDetails( boolean details ) {
+	    showSuccessDetails = details ;
+	}
+	
+	public boolean showSuccessDetails() {
+	    return showSuccessDetails ;
+	}
+	
+	public void addSetDouble( ExcelAntSetDoubleCell setter ) {
+	    addSetter( setter ) ;
+	}
+	
+	public void addSetString( ExcelAntSetStringCell setter ){
+	    addSetter( setter ) ;
+	}
+	
+	public void addSetFormula( ExcelAntSetFormulaCell setter ) {
+	    addSetter( setter ) ;
+	}
+	
+	public void addHandler( ExcelAntHandlerTask handler ) {
+	    testTasks.add( handler ) ;
+	}
+	
+	private void addSetter( ExcelAntSet setter ) {
+//		setters.add( setter );
+		testTasks.add( setter ) ;
+	}
+	
+	public void addEvaluate( ExcelAntEvaluateCell evaluator ) {
+//		evaluators.add( evaluator ) ;
+		testTasks.add( evaluator ) ;
+	}
+	
+//	public LinkedList<ExcelAntSet> getSetters() {
+//		return setters;
+//	}
+
+	protected LinkedList<ExcelAntEvaluateCell> getEvaluators() {
+		return evaluators;
+	}
+	
+	public void execute() throws BuildException {
+	    
+	    Iterator<Task> taskIt = testTasks.iterator() ;
+
+	    int testCount = evaluators.size() ;
+	    int failureCount = 0 ;
+	        
+	    // roll over all sub task elements in one loop.  This allows the
+	    // ordering of the sub elements to be considered. 
+	    while( taskIt.hasNext() ) {
+	        Task task = taskIt.next() ;
+	        
+	       // log( task.getClass().getName(), Project.MSG_INFO ) ;
+	        
+	        if( task instanceof ExcelAntSet ) {
+	            ExcelAntSet set = (ExcelAntSet) task ;
+	            set.setWorkbookUtil(workbookUtil)  ;
+	            set.execute() ;
+	        }
+	        
+	        if( task instanceof ExcelAntHandlerTask ) {
+	            ExcelAntHandlerTask handler = (ExcelAntHandlerTask)task ;
+	            handler.setEAWorkbookUtil(workbookUtil ) ;
+	            handler.execute() ;
+	        }
+	        
+	        if (task instanceof ExcelAntEvaluateCell ) {
+	            ExcelAntEvaluateCell eval = (ExcelAntEvaluateCell)task ;
+	            eval.setWorkbookUtil( workbookUtil ) ;
+	            
+	            if( globalPrecision > 0 ) {
+	                log( "setting globalPrecision to " + globalPrecision + " in the evaluator", Project.MSG_VERBOSE ) ;
+	                eval.setGlobalPrecision( globalPrecision ) ;
+	            }
+
+	            try {
+	                eval.execute() ;
+	                ExcelAntEvaluationResult result = eval.getResult() ;
+	                if( result.didTestPass() && 
+	                        result.evaluationCompleteWithError() == false ) {
+	                    if( showSuccessDetails == true ) {
+	                        log("Succeeded when evaluating " + 
+	                         result.getCellName() + ".  It evaluated to " + 
+                             result.getReturnValue() + " when the value of " + 
+                             eval.getExpectedValue() + " with precision of " + 
+                             eval.getPrecision(), Project.MSG_INFO ) ;
+	                    }
+	                } else {
+	                    if( showFailureDetail == true ) {
+	                        failureMessages.add( "\tFailed to evaluate cell " + 
+	                         result.getCellName() + ".  It evaluated to " + 
+	                         result.getReturnValue() + " when the value of " + 
+	                         eval.getExpectedValue() + " with precision of " + 
+	                         eval.getPrecision() + " was expected." ) ;
+
+	                    }
+	                    passed = false ;
+	                    failureCount++ ;
+	                    
+	                    if( eval.requiredToPass() == true ) {
+	                        throw new BuildException( "\tFailed to evaluate cell " + 
+	                                result.getCellName() + ".  It evaluated to " + 
+	                                result.getReturnValue() + " when the value of " + 
+	                                eval.getExpectedValue() + " with precision of " + 
+	                                eval.getPrecision() + " was expected." ) ;
+	                    }
+	                }
+	            } catch( NullPointerException npe ) {
+	                // this means the cell reference in the test is bad.
+	                log( "Cell assignment " + eval.getCell() + " in test " + getName() + 
+	                      " appears to point to an empy cell.  Please check the " +
+	                      " reference in the ant script.", Project.MSG_ERR ) ;
+	            }
+	        }
+	    }
+ 
+		if( passed == false ) {
+			log( "Test named " + name + " failed because " + failureCount + 
+					 " of " + testCount + " evaluations failed to " + 
+					 "evaluate correctly.", 
+					 Project.MSG_ERR ) ;
+			if( showFailureDetail == true && failureMessages.size() > 0 ) {
+				Iterator<String> failures = failureMessages.iterator() ;
+				while( failures.hasNext() ) {
+					log( failures.next(), Project.MSG_ERR ) ;
+				}
+			}
+		}
+	}
+
+	public boolean didTestPass() {
+		
+		return passed ;
+	}
+ }

Propchange: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunction.java
URL: http://svn.apache.org/viewvc/poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunction.java?rev=1072119&view=auto
==============================================================================
--- poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunction.java (added)
+++ poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunction.java Fri Feb 18 20:04:50 2011
@@ -0,0 +1,55 @@
+/* ====================================================================
+   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.excelant;
+
+import org.apache.tools.ant.taskdefs.Typedef;
+
+/**
+ * This class encapsulates the Strings necessary to create the User Defined
+ * Function instances that will be passed to POI's Evaluator instance.
+ * 
+ * @author Jon Svede ( jon [at] loquatic [dot] com )
+ * @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov )
+ *
+ */
+public class ExcelAntUserDefinedFunction extends Typedef {
+
+	
+	public String functionAlias ;
+	
+	public String className ;
+
+	
+	public ExcelAntUserDefinedFunction() {}
+
+	protected String getFunctionAlias() {
+		return functionAlias;
+	}
+
+	public void setFunctionAlias(String functionAlias) {
+		this.functionAlias = functionAlias;
+	}
+
+	protected String getClassName() {
+		return className;
+	}
+
+	public void setClassName(String className) {
+		this.className = className;
+	}
+}

Propchange: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunction.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/IExcelAntWorkbookHandler.java
URL: http://svn.apache.org/viewvc/poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/IExcelAntWorkbookHandler.java?rev=1072119&view=auto
==============================================================================
--- poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/IExcelAntWorkbookHandler.java (added)
+++ poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/IExcelAntWorkbookHandler.java Fri Feb 18 20:04:50 2011
@@ -0,0 +1,46 @@
+/* ====================================================================
+   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.excelant;
+
+import org.apache.poi.ss.usermodel.Workbook;
+
+
+/**
+ * In Excel there are many ways to handle manipulating a workbook based 
+ * on some arbitrary user action (onChange, etc).  You use this interface
+ * to create classes that will handle the workbook in whatever manner is needed
+ * that cannot be handled by POI.
+ * <p>
+ * For example, suppose that in Excel when you update a cell the workbook
+ * does some calculations and updates other cells based on that change.  In
+ * ExcelAnt you would set the value of the cell then write your own handler
+ * then call that from your Ant task after the set task.
+ * 
+ * @author Jon Svede ( jon [at] loquatic [dot] com )
+ * @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov )
+ *
+ */
+public interface IExcelAntWorkbookHandler {
+    
+    
+    public void setWorkbook( Workbook workbook ) ;
+    
+    public void execute() ;
+    
+
+}

Propchange: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/IExcelAntWorkbookHandler.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/util/ExcelAntEvaluationResult.java
URL: http://svn.apache.org/viewvc/poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/util/ExcelAntEvaluationResult.java?rev=1072119&view=auto
==============================================================================
--- poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/util/ExcelAntEvaluationResult.java (added)
+++ poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/util/ExcelAntEvaluationResult.java Fri Feb 18 20:04:50 2011
@@ -0,0 +1,114 @@
+/* ====================================================================
+   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.excelant.util;
+
+/**
+ * A simple class that encapsulates information about a cell evaluation
+ * from POI.
+ * 
+ * @author Jon Svede ( jon [at] loquatic [dot] com )
+ * @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov )
+ *
+ */
+public class ExcelAntEvaluationResult {
+	
+	/**
+	 * This boolean flag is used to determine if the evaluation completed
+	 * without error.  This alone doesn't ensure that the evaluation was 
+	 * sucessful.
+	 */
+	private boolean evaluationCompletedWithError ;
+	
+	/**
+	 * This boolean flag is used to determine if the result was within
+	 * the specified precision.
+	 */
+	private boolean didPass ;
+	
+	/**
+	 * This is the actual value returned from the evaluation.
+	 */
+	private double returnValue ;
+	
+	/**
+	 * Any error message String values that need to be returned.
+	 */
+	private String errorMessage ;
+	
+	/**
+	 * Stores the absolute value of the delta for this evaluation.
+	 */
+	private double actualDelta ;
+	
+	/**
+	 * This stores the fully qualified cell name (sheetName!cellId).
+	 */
+	private String cellName ;
+	
+	
+
+	public ExcelAntEvaluationResult( boolean completedWithError,
+			                 boolean passed, 
+			                 double retValue, 
+			                 String errMessage, 
+			                 double delta,
+			                 String cellId ) {
+
+		evaluationCompletedWithError = completedWithError;
+		didPass = passed;
+		returnValue = retValue;
+		errorMessage = errMessage;
+		actualDelta = delta ;
+		cellName = cellId ;
+	}
+
+	public double getReturnValue() {
+		return returnValue;
+	}
+
+	public String getErrorMessage() {
+		return errorMessage;
+	}
+	
+	public boolean didTestPass() {
+		return didPass ;
+	}
+	
+	public boolean evaluationCompleteWithError() {
+		return evaluationCompletedWithError ;
+	}
+	
+	public double getDelta() {
+		return actualDelta ;
+	}
+	
+	public String getCellName() {
+		return cellName ;
+	}
+
+	@Override
+	public String toString() {
+		return "ExcelAntEvaluationResult [evaluationCompletedWithError="
+				+ evaluationCompletedWithError + ", didPass=" + didPass
+				+ ", returnValue=" + returnValue + ", errorMessage="
+				+ errorMessage + ", actualDelta=" + actualDelta + ", cellName="
+				+ cellName + "]";
+	}
+
+	
+}

Propchange: poi/branches/excelant/src/excelant/java/org/apache/poi/ss/excelant/util/ExcelAntEvaluationResult.java
------------------------------------------------------------------------------
    svn:executable = *



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


Mime
View raw message