📄 function.java~
字号:
/*********************************************************************
*
* Copyright (C) 2002 Andrew Khan
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
package jxl.biff.formula;
import common.Logger;
import jxl.WorkbookSettings;
/**
* An enumeration detailing the Excel function codes
*/
final class Function
{
/**
* The logger
*/
private static Logger logger = Logger.getLogger(Function.class);
/**
* The code which applies to this function
*/
private final int code;
/**
* The property name of this function
*/
private final String name;
/**
* The number of args this function expects
*/
private final int numArgs;
/**
* All available functions. This attribute is package protected in order
* to enable the FunctionNames to initialize
*/
private static Function[] functions = new Function[0];
/**
* Constructor
* Sets the token value and adds this token to the array of all token
*
* @param v the biff code for the token
* @param s the string
* @param a the number of arguments
*/
private Function(int v, String s, int a)
{
code = v;
name = s;
numArgs = a;
// Grow the array
Function[] newarray = new Function[functions.length + 1];
System.arraycopy(functions, 0, newarray, 0, functions.length);
newarray[functions.length] = this;
functions = newarray;
}
/**
* Standard hash code method
*
* @return the hash code
*/
public int hashCode()
{
return code;
}
/**
* Gets the function code - used when generating token data
*
* @return the code
*/
int getCode()
{
return code;
}
/**
* Gets the property name. Used by the FunctionNames object when initializing
* the locale specific names
*
* @return the property name for this function
*/
String getPropertyName()
{
return name;
}
/**
* Gets the function name
* @param ws the workbook settings
* @return the function name
*/
String getName(WorkbookSettings ws)
{
FunctionNames fn = ws.getFunctionNames();
return fn.getName(this);
}
/**
* Gets the number of arguments for this function
*
* @return the number of arguments
*/
int getNumArgs()
{
return numArgs;
}
/**
* Gets the type object from its integer value
*
* @param v the function value
* @return the function
*/
public static Function getFunction(int v)
{
Function f = null;
for (int i = 0; i < functions.length; i++)
{
if (functions[i].code == v)
{
f = functions[i];
break;
}
}
return f != null ? f : UNKNOWN;
}
/**
* Gets the type object from its string value. Used when parsing strings
*
* @param v the function name
* @param ws the workbook settings
* @return the function
*/
public static Function getFunction(String v, WorkbookSettings ws)
{
FunctionNames fn = ws.getFunctionNames();
Function f = fn.getFunction(v);
return f != null ? f : UNKNOWN;
}
/**
* Accessor for all the functions, used by the internationalization
* work around
*
* @return all the functions
*/
static Function[] getFunctions()
{
return functions;
}
// The functions
public static final Function COUNT =
new Function(0x0, "count", 0xff);
public static final Function ATTRIBUTE = new Function(0x1, "", 0xff);
public static final Function ISNA =
new Function(0x2, "isna", 1);
public static final Function ISERROR =
new Function(0x3, "iserror", 1);
public static final Function SUM =
new Function(0x4, "sum", 0xff);
public static final Function AVERAGE =
new Function(0x5, "average", 0xff);
public static final Function MIN =
new Function(0x6, "min", 0xff);
public static final Function MAX =
new Function(0x7, "max", 0xff);
public static final Function ROW =
new Function(0x8, "row", 0xff);
public static final Function COLUMN =
new Function(0x9, "column", 0xff);
public static final Function NA =
new Function(0xa, "na", 0);
public static final Function NPV =
new Function(0xb, "npv", 0xff);
public static final Function STDEV =
new Function(0xc, "stdev", 0xff);
public static final Function DOLLAR =
new Function(0xd, "dollar", 2);
public static final Function FIXED =
new Function(0xe, "fixed", 0xff);
public static final Function SIN =
new Function(0xf, "sin", 1);
public static final Function COS =
new Function(0x10, "cos", 1);
public static final Function TAN =
new Function(0x11, "tan", 1);
public static final Function ATAN =
new Function(0x12, "atan", 1);
public static final Function PI =
new Function(0x13, "pi", 0);
public static final Function SQRT =
new Function(0x14, "sqrt", 1);
public static final Function EXP =
new Function(0x15, "exp", 1);
public static final Function LN =
new Function(0x16, "ln", 1);
public static final Function LOG10 =
new Function(0x17, "log10", 1);
public static final Function ABS =
new Function(0x18, "abs", 1);
public static final Function INT =
new Function(0x19, "int", 1);
public static final Function SIGN =
new Function(0x1a, "sign", 1);
public static final Function ROUND =
new Function(0x1b, "round", 2);
public static final Function LOOKUP =
new Function(0x1c, "lookup", 2);
public static final Function INDEX =
new Function(0x1d, "index", 3);
public static final Function REPT = new Function(0x1e, "rept", 2);
public static final Function MID =
new Function(0x1f, "mid", 3);
public static final Function LEN =
new Function(0x20, "len", 1);
public static final Function VALUE =
new Function(0x21, "value", 1);
public static final Function TRUE =
new Function(0x22, "true", 0);
public static final Function FALSE =
new Function(0x23, "false", 0);
public static final Function AND =
new Function(0x24, "and", 0xff);
public static final Function OR =
new Function(0x25, "or", 0xff);
public static final Function NOT =
new Function(0x26, "not", 1);
public static final Function MOD =
new Function(0x27, "mod", 2);
public static final Function DCOUNT =
new Function(0x28, "dcount", 3);
public static final Function DSUM =
new Function(0x29, "dsum", 3);
public static final Function DAVERAGE =
new Function(0x2a, "daverage", 3);
public static final Function DMIN =
new Function(0x2b, "dmin", 3);
public static final Function DMAX =
new Function(0x2c, "dmax", 3);
public static final Function DSTDEV =
new Function(0x2d, "dstdev", 3);
public static final Function VAR =
new Function(0x2e, "var", 0xff);
public static final Function DVAR =
new Function(0x2f, "dvar", 3);
public static final Function TEXT =
new Function(0x30, "text", 2);
public static final Function LINEST =
new Function(0x31, "linest", 0xff);
public static final Function TREND =
new Function(0x32, "trend", 0xff);
public static final Function LOGEST =
new Function(0x33, "logest", 0xff);
public static final Function GROWTH =
new Function(0x34, "growth", 0xff);
//public static final Function GOTO = new Function(0x35, "GOTO",);
//public static final Function HALT = new Function(0x36, "HALT",);
public static final Function PV =
new Function(0x38, "pv", 0xff);
public static final Function FV =
new Function(0x39, "fv", 0xff);
public static final Function NPER =
new Function(0x3a, "nper", 0xff);
public static final Function PMT =
new Function(0x3b, "pmt", 0xff);
public static final Function RATE =
new Function(0x3c, "rate", 0xff);
//public static final Function MIRR = new Function(0x3d, "MIRR",);
//public static final Function IRR = new Function(0x3e, "IRR",);
public static final Function RAND =
new Function(0x3f, "rand", 0);
public static final Function MATCH =
new Function(0x40, "match", 3);
public static final Function DATE =
new Function(0x41, "date", 3);
public static final Function TIME =
new Function(0x42, "time", 3);
public static final Function DAY =
new Function(0x43, "day", 1);
public static final Function MONTH =
new Function(0x44, "month", 1);
public static final Function YEAR =
new Function(0x45, "year", 1);
public static final Function WEEKDAY =
new Function(0x46, "weekday", 2);
public static final Function HOUR =
new Function(0x47, "hour", 1);
public static final Function MINUTE =
new Function(0x48, "minute", 1);
public static final Function SECOND =
new Function(0x49, "second", 1);
public static final Function NOW =
new Function(0x4a, "now", 0);
public static final Function AREAS =
new Function(0x4b, "areas", 0xff);
public static final Function ROWS =
new Function(0x4c, "rows", 1);
public static final Function COLUMNS =
new Function(0x4d, "columns", 0xff);
public static final Function OFFSET =
new Function(0x4e, "offset", 0xff);
//public static final Function ABSREF = new Function(0x4f, "ABSREF",);
//public static final Function RELREF = new Function(0x50, "RELREF",);
//public static final Function ARGUMENT = new Function(0x51,"ARGUMENT",);
public static final Function SEARCH = new Function(0x52, "search", 0xff);
public static final Function TRANSPOSE =
new Function(0x53, "transpose", 0xff);
public static final Function ERROR =
new Function(0x54, "error", 1);
//public static final Function STEP = new Function(0x55, "STEP",);
public static final Function TYPE =
new Function(0x56, "type", 1);
//public static final Function ECHO = new Function(0x57, "ECHO",);
//public static final Function SETNAME = new Function(0x58, "SETNAME",);
//public static final Function CALLER = new Function(0x59, "CALLER",);
//public static final Function DEREF = new Function(0x5a, "DEREF",);
//public static final Function WINDOWS = new Function(0x5b, "WINDOWS",);
//public static final Function SERIES = new Function(0x5c, "SERIES",);
//public static final Function DOCUMENTS = new Function(0x5d,"DOCUMENTS",);
//public static final Function ACTIVECELL = new Function(0x5e,"ACTIVECELL",);
//public static final Function SELECTION = new Function(0x5f,"SELECTION",);
//public static final Function RESULT = new Function(0x60, "RESULT",);
public static final Function ATAN2 =
new Function(0x61, "atan2", 1);
public static final Function ASIN =
new Function(0x62, "asin", 1);
public static final Function ACOS =
new Function(0x63, "acos", 1);
public static final Function CHOOSE =
new Function(0x64, "choose", 0xff);
public static final Function HLOOKUP =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -