1 19 20 package jxl.biff.formula; 21 22 import java.util.HashMap ; 23 import java.util.ResourceBundle ; 24 import java.util.Locale ; 25 26 import common.Logger; 27 28 import jxl.WorkbookSettings; 29 30 33 class Function 34 { 35 38 private static Logger logger = Logger.getLogger(Function.class); 39 40 43 private final int code; 44 45 48 private final String name; 49 50 53 private final int numArgs; 54 55 56 60 static Function[] functions = new Function[0]; 61 62 63 69 private Function(int v, String s, int a) 70 { 71 code = v; 72 name = s; 73 numArgs = a; 74 75 Function[] newarray = new Function[functions.length+1]; 77 System.arraycopy(functions, 0, newarray, 0, functions.length); 78 newarray[functions.length] = this; 79 functions = newarray; 80 } 81 82 87 public int hashCode() 88 { 89 return code; 90 } 91 92 97 int getCode() 98 { 99 return code; 100 } 101 102 108 String getPropertyName() 109 { 110 return name; 111 } 112 113 118 String getName(WorkbookSettings ws) 119 { 120 FunctionNames fn = ws.getFunctionNames(); 121 return fn.getName(this); 122 } 123 124 127 int getNumArgs() 128 { 129 return numArgs; 130 } 131 132 135 public static Function getFunction(int v) 136 { 137 Function f = null; 138 139 for (int i = 0; i < functions.length; i++) 140 { 141 if (functions[i].code == v) 142 { 143 f = functions[i]; 144 break; 145 } 146 } 147 148 return f != null ? f : UNKNOWN; 149 } 150 151 157 public static Function getFunction(String v, WorkbookSettings ws) 158 { 159 FunctionNames fn = ws.getFunctionNames(); 160 Function f = fn.getFunction(v); 161 return f != null ? f : UNKNOWN; 162 } 163 164 166 public static final Function COUNT = 167 new Function(0x0, "count",0xff); 168 public static final Function ATTRIBUTE = new Function(0x1, "", 0xff); 169 public static final Function ISNA = 170 new Function(0x2, "isna",1); 171 public static final Function ISERROR = 172 new Function(0x3, "iserror", 1); 173 public static final Function SUM = 174 new Function(0x4, "sum",0xff); 175 public static final Function AVERAGE = 176 new Function(0x5, "average",0xff); 177 public static final Function MIN = 178 new Function(0x6, "min",0xff); 179 public static final Function MAX = 180 new Function(0x7, "max",0xff); 181 public static final Function ROW = 182 new Function(0x8, "row",0xff); 183 public static final Function COLUMN = 184 new Function(0x9, "column",1); 185 public static final Function NA = 186 new Function(0xa, "na",0); 187 public static final Function NPV = 188 new Function(0xb, "npv", 0xff); 189 public static final Function STDEV = 190 new Function(0xc, "stdev", 0xff); 191 public static final Function DOLLAR = 192 new Function(0xd, "dollar",2); 193 public static final Function FIXED = 194 new Function(0xe, "fixed",0xff); 195 public static final Function SIN = 196 new Function(0xf, "sin",1); 197 public static final Function COS = 198 new Function(0x10, "cos",1); 199 public static final Function TAN = 200 new Function(0x11, "tan",1); 201 public static final Function ATAN = 202 new Function(0x12, "atan",1); 203 public static final Function PI = 204 new Function(0x13, "pi",0); 205 public static final Function SQRT = 206 new Function(0x14, "sqrt",1); 207 public static final Function EXP = 208 new Function(0x15, "exp",1); 209 public static final Function LN = 210 new Function(0x16, "ln",1); 211 public static final Function LOG10 = 212 new Function(0x17, "log10",1); 213 public static final Function ABS = 214 new Function(0x18, "abs",1); 215 public static final Function INT = 216 new Function(0x19, "int",1); 217 public static final Function SIGN = 218 new Function(0x1a, "sign",1); 219 public static final Function ROUND = 220 new Function(0x1b, "round",2); 221 public static final Function LOOKUP = 222 new Function(0x1c, "lookup", 2); 223 public static final Function INDEX = 224 new Function(0x1d, "index",3); 225 public static final Function MID = 227 new Function(0x1f, "mid",3); 228 public static final Function LEN = 229 new Function(0x20, "len",1); 230 public static final Function VALUE = 231 new Function(0x21, "value",1); 232 public static final Function TRUE = 233 new Function(0x22, "true",0); 234 public static final Function FALSE = 235 new Function(0x23, "false",0); 236 public static final Function AND = 237 new Function(0x24, "and",0xff); 238 public static final Function OR = 239 new Function(0x25, "or",0xff); 240 public static final Function NOT = 241 new Function(0x26, "not",1); 242 public static final Function MOD = 243 new Function(0x27, "mod",2); 244 public static final Function DCOUNT = 245 new Function(0x28, "dcount",3); 246 public static final Function DSUM = 247 new Function(0x29, "dsum",3); 248 public static final Function DAVERAGE = 249 new Function(0x2a, "daverage",3); 250 public static final Function DMIN = 251 new Function(0x2b, "dmin",3); 252 public static final Function DMAX = 253 new Function(0x2c, "dmax",3); 254 public static final Function DSTDEV = 255 new Function(0x2d, "dstdev",3); 256 public static final Function VAR = 257 new Function(0x2e, "var",0xff); 258 public static final Function DVAR = 259 new Function(0x2f, "dvar",3); 260 public static final Function TEXT = 261 new Function(0x30, "text",2); 262 public static final Function LINEST = 263 new Function(0x31, "linest", 0xff); 264 public static final Function TREND = 265 new Function(0x32, "trend",0xff); 266 public static final Function LOGEST = 267 new Function(0x33, "logest",0xff); 268 public static final Function GROWTH = 269 new Function(0x34, "growth",0xff); 270 public static final Function PV = 273 new Function(0x38, "pv", 0xff); 274 public static final Function FV = 275 new Function(0x39, "fv",0xff); 276 public static final Function NPER = 277 new Function(0x3a, "nper",0xff); 278 public static final Function PMT = 279 new Function(0x3b, "pmt",0xff); 280 public static final Function RATE = 281 new Function(0x3c, "rate",0xff); 282 public static final Function RAND = 285 new Function(0x3f, "rand",0); 286 public static final Function MATCH = 287 new Function(0x40, "match",3); 288 public static final Function DATE = 289 new Function(0x41, "date",3); 290 public static final Function TIME = 291 new Function(0x42, "time",3); 292 public static final Function DAY = 293 new Function(0x43, "day",1); 294 public static final Function MONTH = 295 new Function(0x44, "month",1); 296 public static final Function YEAR = 297 new Function(0x45, "year",1); 298 public static final Function WEEKDAY = 299 new Function(0x46, "weekday",2); 300 public static final Function HOUR = 301 new Function(0x47, "hour",1); 302 public static final Function MINUTE = 303 new Function(0x48, "minute", 1); 304 public static final Function SECOND = 305 new Function(0x49, "second",1); 306 public static final Function NOW = 307 new Function(0x4a, "now",0); 308 public static final Function AREAS = 309 new Function(0x4b, "areas",0xff); 310 public static final Function ROWS = 311 new Function(0x4c, "rows", 1); 312 public static final Function COLUMNS = 313 new Function(0x4d,"columns",0xff); 314 public static final Function OFFSET = 315 new Function(0x4e, "offset", 0xff); 316 public static final Function TRANSPOSE = 321 new Function(0x53, "transpose",0xff); 322 public static final Function ERROR = 323 new Function(0x54, "error",1); 324 public static final Function TYPE = 326 new Function(0x56, "type",1); 327 public static final Function ATAN2 = 338 new Function(0x61, "atan2", 1); 339 public static final Function ASIN = 340 new Function(0x62, "asin",1); 341 public static final Function ACOS = 342 new Function(0x63, "acos",1); 343 public static final Function CHOOSE = 344 new Function(0x64, "choose", 0xff); 345 public static final Function HLOOKUP = 346 new Function(0x65,"hlookup",0xff); 347 public static final Function VLOOKUP = 348 new Function(0x66,"vlookup",0xff); 349 public static final Function ISREF = 352 new Function(0x69, "isref",1); 353 public static final Function LOG = 357 new Function(0x6d, "log", 0xff); 358 public static final Function CHAR = 360 new Function(0x6f, "char",1); 361 public static final Function LOWER = 362 new Function(0x70, "lower",1); 363 public static final Function UPPER = 364 new Function(0x71, "upper",1); 365 public static final Function PROPER = 366 new Function(0x72, "proper",1); 367 public static final Function LEFT = 368 new Function(0x73, "left",0xff); 369 public static final Function RIGHT = 370 new Function(0x74, "right",0xff); 371 public static final Function EXACT = 372 new Function(0x75, "exact",2); 373 public static final Function TRIM = 374 new Function(0x76, "trim",1); 375 public static final Function REPLACE = 376 new Function(0x77, "replace",4); 377 public static final Function SUBSTITUTE = 378 new Function(0x78,"substitute", 0xff); 379 public static final Function CODE = 380 new Function(0x79, "code",1); 381 public static final Function FIND = 384 new Function(0x7c, "find",0xff); 385 public static final Function CELL = 386 new Function(0x7d, "cell",2); 387 public static final Function ISERR = 388 new Function(0x7e, "iserr",1); 389 public static final Function ISTEXT = 390 new Function(0x7f, "istext",1); 391 public static final Function ISNUMBER = 392 new Function(0x80, "isnumber",1); 393 public static final Function ISBLANK = 394 new Function(0x81, "isblank",1); 395 public static final Function T = 396 new Function(0x82, "t",1); 397 public static final Function N = 398 new Function(0x83, "n",1); 399 public static final Function DATEVALUE = 408 new Function(0x8c,"datevalue",1); 409 public static final Function TIMEVALUE = 410 new Function(0x8d,"timevalue",1); 411 public static final Function SLN = 412 new Function(0x8e, "sln",3); 413 public static final Function SYD = 414 new Function(0x8f, "syd",3); 415 public static final Function DDB = 416 new Function(0x90, "ddb",0xff); 417 public static final Function INDIRECT = 421 new Function(0x94,"indirect",0xff); 422 public static final Function CLEAN = 436 new Function(0xa2, "clean",1); 437 public static final Function MDETERM = 438 new Function(0xa3, "mdeterm",0xff); 439 public static final Function MINVERSE = 440 new Function(0xa4,"minverse",0xff); 441 public static final Function MMULT = 442 new Function(0xa5, "mmult",0xff); 443 public static final Function IPMT = 445 new Function(0xa7, "ipmt",0xff); 446 public static final Function PPMT = 447 new Function(0xa8, "ppmt",0xff); 448 public static final Function COUNTA = 449 new Function(0xa9, "counta",0xff); 450 public static final Function PRODUCT = 451 new Function(0xb7,"product",0xff); 452 public static final Function FACT = 453 new Function(0xb8, "fact",1); 454 public static final Function DPRODUCT = 459 new Function(0xbd, "dproduct",3); 460 public static final Function ISNONTEXT = 461 new Function(0xbe,"isnontext",1); 462 public static final Function STDEVP = 465 new Function(0xc1, "stdevp",0xff); 466 public static final Function VARP = 467 new Function(0xc2, "varp",0xff); 468 public static final Function DSTDEVP = 469 new Function(0xc3,"dstdevp",0xff); 470 public static final Function DVARP = 471 new Function(0xc4, "dvarp",0xff); 472 public static final Function TRUNC = 473 new Function(0xc5, "trunc",0xff); 474 public static final Function ISLOGICAL = 475 new Function(0xc6,"islogical",1); 476 public static final Function DCOUNTA = 477 new Function(0xc7,"dcounta",0xff); 478 public static final Function FINDB = 479 new Function(0xcd, "findb",0xff); 480 public static final Function SEARCHB = 481 new Function(0xce, "searchb",3); 482 public static final Function REPLACEB = 483 new Function(0xcf, "replaceb",4); 484 public static final Function LEFTB = 485 new Function(0xd0, "leftb",0xff); 486 public static final Function RIGHTB = 487 new Function(0xd1, "rightb",0xff); 488 public static final Function MIDB = 489 new Function(0xd2, "midb",3); 490 public static final Function LENB = 491 new Function(0xd3, "lenb",1); 492 public static final Function ROUNDUP = 493 new Function(0xd4,"roundup",2); 494 public static final Function ROUNDDOWN = 495 new Function(0xd5,"rounddown",2); 496 public static final Function RANK = 497 new Function(0xd8, "rank",0xff); 498 public static final Function ADDRESS = 499 new Function(0xdb,"address",0xff); 500 public static final Function AYS360 = 501 new Function(0xdc,"days360",0xff); 502 public static final Function ODAY = 503 new Function(0xdd, "today",0); 504 public static final Function VDB = 505 new Function(0xde, "vdb",0xff); 506 public static final Function MEDIAN = 507 new Function(0xe3, "median",0xff); 508 public static final Function SUMPRODUCT = 509 new Function(0xe4,"sumproduct",0xff); 510 public static final Function SINH = 511 new Function(0xe5, "sinh",1); 512 public static final Function COSH = 513 new Function(0xe6, "cosh",1); 514 public static final Function TANH = 515 new Function(0xe7, "tanh",1); 516 public static final Function ASINH = 517 new Function(0xe8, "asinh",1); 518 public static final Function ACOSH = 519 new Function(0xe9, "acosh",1); 520 public static final Function ATANH = 521 new Function(0xea, "atanh",1); 522 public static final Function INFO = 523 new Function(0xf4, "info", 1); 524 public static final Function AVEDEV = 525 new Function(0x10d, "avedev",0XFF); 526 public static final Function BETADIST = 527 new Function(0x10e,"betadist",0XFF); 528 public static final Function GAMMALN = 529 new Function(0x10f, "gammaln",1); 530 public static final Function BETAINV = 531 new Function(0x110,"betainv",0XFF); 532 public static final Function BINOMDIST = 533 new Function(0x111,"binomdist",4); 534 public static final Function CHIDIST = 535 new Function(0x112, "chidist",2); 536 public static final Function CHIINV = 537 new Function(0x113, "chiinv",2); 538 public static final Function COMBIN = 539 new Function(0x114, "combin",2); 540 public static final Function CONFIDENCE = 541 new Function(0x115,"confidence",3); 542 public static final Function CRITBINOM = 543 new Function(0x116,"critbinom",3); 544 public static final Function EVEN = 545 new Function(0x117, "even",1); 546 public static final Function EXPONDIST = 547 new Function(0x118,"expondist",3); 548 public static final Function FDIST = 549 new Function(0x119, "fdist",3); 550 public static final Function FINV = 551 new Function(0x11a, "finv",3); 552 public static final Function FISHER = 553 new Function(0x11b, "fisher",1); 554 public static final Function FISHERINV = 555 new Function(0x11c,"fisherinv",1); 556 public static final Function FLOOR = 557 new Function(0x11d, "floor",2); 558 public static final Function GAMMADIST = 559 new Function(0x11e,"gammadist",4); 560 public static final Function GAMMAINV = 561 new Function(0x11f,"gammainv",3); 562 public static final Function CEILING = 563 new Function(0x120, "ceiling",2); 564 public static final Function HYPGEOMDIST = 565 new Function(0x121,"hypgeomdist",4); 566 public static final Function LOGNORMDIST = 567 new Function(0x122,"lognormdist",3); 568 public static final Function LOGINV = 569 new Function(0x123, "loginv",3); 570 public static final Function NEGBINOMDIST = 571 new Function(0x124,"negbinomdist",3); 572 public static final Function NORMDIST = 573 new Function(0x125,"normdist",4); 574 public static final Function NORMSDIST = 575 new Function(0x126,"normsdist",1); 576 public static final Function NORMINV = 577 new Function(0x127, "norminv",3); 578 public static final Function NORMSINV = 579 new Function(0x128,"normsinv",1); 580 public static final Function STANDARDIZE = 581 new Function(0x129,"standardize",3); 582 public static final Function ODD = 583 new Function(0x12a, "odd",1); 584 public static final Function PERMUT = 585 new Function(0x12b, "permut",2); 586 public static final Function POISSON = 587 new Function(0x12c, "poisson",3); 588 public static final Function TDIST = 589 new Function(0x12d, "tdist",3); 590 public static final Function WEIBULL = 591 new Function(0x12e, "weibull",4); 592 public static final Function SUMXMY2 = 593 new Function(303, "sumxmy2",0xff); 594 public static final Function SUMX2MY2 = 595 new Function(304,"sumx2my2",0xff); 596 public static final Function SUMX2PY2 = 597 new Function(305,"sumx2py2",0xff); 598 public static final Function CHITEST = 599 new Function(0x132,"chitest",0xff); 600 public static final Function CORREL = 601 new Function(0x133, "correl",0xff); 602 public static final Function COVAR = 603 new Function(0x134, "covar",0xff); 604 public static final Function FORECAST = 605 new Function(0x135,"forecast",0xff); 606 public static final Function FTEST = 607 new Function(0x136, "ftest",0xff); 608 public static final Function INTERCEPT = 609 new Function(0x137,"intercept",0xff); 610 public static final Function PEARSON = 611 new Function(0x138,"pearson",0xff); 612 public static final Function RSQ = 613 new Function(0x139, "rsq",0xff); 614 public static final Function STEYX = 615 new Function(0x13a, "steyx",0xff); 616 public static final Function SLOPE = 617 new Function(0x13b, "slope",2); 618 public static final Function TTEST = 619 new Function(0x13c, "ttest",0xff); 620 public static final Function PROB = 621 new Function(0x13d, "prob",0xff); 622 public static final Function DEVSQ = 623 new Function(0x13e, "devsq",0xff); 624 public static final Function GEOMEAN = 625 new Function(0x13f,"geomean",0xff); 626 public static final Function HARMEAN = 627 new Function(0x140,"harmean",0xff); 628 public static final Function SUMSQ = 629 new Function(0x141, "sumsq",0xff); 630 public static final Function KURT = 631 new Function(0x142, "kurt",0xff); 632 public static final Function SKEW = 633 new Function(0x143, "skew",0xff); 634 public static final Function ZTEST = 635 new Function(0x144, "ztest",0xff); 636 public static final Function LARGE = 637 new Function(0x145, "large",0xff); 638 public static final Function SMALL = 639 new Function(0x146, "small",0xff); 640 public static final Function QUARTILE = 641 new Function(0x147,"quartile",0xff); 642 public static final Function PERCENTILE = 643 new Function(0x148,"percentile",0xff); 644 public static final Function PERCENTRANK = 645 new Function(0x149,"percentrank",0xff); 646 public static final Function MODE = 647 new Function(0x14a, "mode",0xff); 648 public static final Function TRIMMEAN = 649 new Function(0x14b,"trimmean",0xff); 650 public static final Function TINV = 651 new Function(0x14c, "tinv",2); 652 public static final Function CONCATENATE = 653 new Function(0x150,"concatenate",0xff); 654 public static final Function POWER = 655 new Function(0x151, "power",2); 656 public static final Function RADIANS = 657 new Function(0x156, "radians",1); 658 public static final Function DEGREES = 659 new Function(0x157, "degrees",1); 660 public static final Function SUBTOTAL = 661 new Function(0x158, "subtotal",0xff); 662 public static final Function SUMIF = 663 new Function(0x159, "sumif",0xff); 664 public static final Function COUNTIF = 665 new Function(0x15a, "countif",2); 666 public static final Function COUNTBLANK = 667 new Function(0x15b,"countblank",1); 668 public static final Function HYPERLINK = 669 new Function(0x167,"hyperlink",2); 670 public static final Function AVERAGEA = 671 new Function(0x169,"averagea",0xff); 672 public static final Function MAXA = 673 new Function(0x16a, "maxa",0xff); 674 public static final Function MINA = 675 new Function(0x16b, "mina",0xff); 676 public static final Function STDEVPA = 677 new Function(0x16c,"stdevpa",0xff); 678 public static final Function VARPA = 679 new Function(0x16d, "varpa",0xff); 680 public static final Function STDEVA = 681 new Function(0x16e, "stdeva",0xff); 682 public static final Function VARA = 683 new Function(0x16f, "vara",0xff); 684 685 public static final Function IF = 688 new Function(0xfffe, "if", 0xff); 689 690 public static final Function UNKNOWN = new Function(0xffff, "", 0); 692 } 693 | Popular Tags |