public class ExcelAntWorkbookUtil
extends org.apache.tools.ant.taskdefs.Typedef
Modifier | Constructor and Description |
---|---|
protected |
ExcelAntWorkbookUtil(java.lang.String fName)
Constructs an instance using a String that contains the fully qualified
path of the Excel file.
|
protected |
ExcelAntWorkbookUtil(Workbook wb)
Constructs an instance based on a Workbook instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addFunction(java.lang.String name,
FreeRefFunction func)
Updates the internal HashMap of functions with instance and alias passed
in.
|
void |
addFunction(java.lang.String name,
java.lang.String clazzName)
Used to add a UDF to the evaluator.
|
ExcelAntEvaluationResult |
evaluateCell(java.lang.String cellName,
double expectedValue,
double precision)
Uses a String in standard Excel format (SheetName!CellId) to locate a
cell and evaluate it.
|
double |
getCellAsDouble(java.lang.String cellName)
Returns the value of the Cell as a double.
|
java.lang.String |
getCellAsString(java.lang.String cellName)
Returns a Cell as a String value.
|
protected FormulaEvaluator |
getEvaluator(java.lang.String fileName)
Returns a formula evaluator that is loaded with the functions that
have been supplied.
|
java.lang.String |
getFileName()
Returns the fileName that was used to initialize this instance.
|
protected UDFFinder |
getFunctions()
returns a UDFFinder that contains all of the functions added.
|
java.util.List<java.lang.String> |
getSheets()
Returns the list of sheet names.
|
Workbook |
getWorkbook()
Returns the Workbook instance associated with this WorkbookUtil.
|
void |
setDateValue(java.lang.String cellName,
java.util.Date date)
Utility method for setting the value of a Cell with a Date.
|
void |
setDoubleValue(java.lang.String cellName,
double value)
This method uses a String in standard Excel format (SheetName!CellId) to
locate the cell and set it to the value of the double in value.
|
void |
setFormulaValue(java.lang.String cellName,
java.lang.String formula)
Utility method for setting the value of a Cell with a Formula.
|
void |
setStringValue(java.lang.String cellName,
java.lang.String value)
Utility method for setting the value of a Cell with a String.
|
addDefinition, execute, getClassname, getFile, getName, getResource, loadProperties, makeResourceFromURI, setAdapter, setAdapterClass, setAdaptTo, setAdaptToClass, setAntlib, setClassname, setFile, setFormat, setName, setOnError, setResource, setRestrict
createClasspath, createLoader, getClasspath, getClasspathId, getLoaderId, hasCpDelegate, init, isReverseLoader, setClasspath, setClasspathRef, setLoaderRef, setReverseLoader
getAntlibClassLoader, getURI, setAntlibClassLoader, setURI
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
protected ExcelAntWorkbookUtil(java.lang.String fName)
fName
- The fully qualified path of the Excel file.org.apache.tools.ant.BuildException
- If the workbook cannot be loaded.protected ExcelAntWorkbookUtil(Workbook wb)
wb
- The Workbook to use for this instance.public void addFunction(java.lang.String name, java.lang.String clazzName) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
name
- The name of the function to addclazzName
- The class which implements this functionjava.lang.ClassNotFoundException
- if the class cannot be foundjava.lang.InstantiationException
- if the class cannot be constructedjava.lang.IllegalAccessException
- if the constructor or the class is not accessiblejava.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
protected void addFunction(java.lang.String name, FreeRefFunction func)
name
- the name of the function to replacefunc
- the function to useprotected UDFFinder getFunctions()
UDFFinder
which can be used to
lookup functionsprotected FormulaEvaluator getEvaluator(java.lang.String fileName)
fileName
- Specifies if XSSF or HSSF should be used for
the evaluatorFormulaEvaluator
constructed accordinglypublic Workbook getWorkbook()
public java.lang.String getFileName()
public java.util.List<java.lang.String> getSheets()
public void setDoubleValue(java.lang.String cellName, double value)
public void setStringValue(java.lang.String cellName, java.lang.String value)
public void setFormulaValue(java.lang.String cellName, java.lang.String formula)
public void setDateValue(java.lang.String cellName, java.util.Date date)
public ExcelAntEvaluationResult evaluateCell(java.lang.String cellName, double expectedValue, double precision)
public java.lang.String getCellAsString(java.lang.String cellName)
public double getCellAsDouble(java.lang.String cellName)
Copyright 2022 The Apache Software Foundation or its licensors, as applicable.]]>