You are here

private function PHPExcel_Reader_Excel5::_getNextToken in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php \PHPExcel_Reader_Excel5::_getNextToken()

* Fetch next token from binary formula data * *

Parameters

string Formula data: * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas * @return array * @throws PHPExcel_Reader_Exception

1 call to PHPExcel_Reader_Excel5::_getNextToken()
PHPExcel_Reader_Excel5::_getFormulaFromData in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php
* Take formula data and additional data for formula and return human readable formula * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php, line 5447

Class

PHPExcel_Reader_Excel5
PHPExcel_Reader_Excel5

Code

private function _getNextToken($formulaData, $baseCell = 'A1') {

  // offset: 0; size: 1; token id
  $id = ord($formulaData[0]);

  // token id
  $name = false;

  // initialize token name
  switch ($id) {
    case 0x3:
      $name = 'tAdd';
      $size = 1;
      $data = '+';
      break;
    case 0x4:
      $name = 'tSub';
      $size = 1;
      $data = '-';
      break;
    case 0x5:
      $name = 'tMul';
      $size = 1;
      $data = '*';
      break;
    case 0x6:
      $name = 'tDiv';
      $size = 1;
      $data = '/';
      break;
    case 0x7:
      $name = 'tPower';
      $size = 1;
      $data = '^';
      break;
    case 0x8:
      $name = 'tConcat';
      $size = 1;
      $data = '&';
      break;
    case 0x9:
      $name = 'tLT';
      $size = 1;
      $data = '<';
      break;
    case 0xa:
      $name = 'tLE';
      $size = 1;
      $data = '<=';
      break;
    case 0xb:
      $name = 'tEQ';
      $size = 1;
      $data = '=';
      break;
    case 0xc:
      $name = 'tGE';
      $size = 1;
      $data = '>=';
      break;
    case 0xd:
      $name = 'tGT';
      $size = 1;
      $data = '>';
      break;
    case 0xe:
      $name = 'tNE';
      $size = 1;
      $data = '<>';
      break;
    case 0xf:
      $name = 'tIsect';
      $size = 1;
      $data = ' ';
      break;
    case 0x10:
      $name = 'tList';
      $size = 1;
      $data = ',';
      break;
    case 0x11:
      $name = 'tRange';
      $size = 1;
      $data = ':';
      break;
    case 0x12:
      $name = 'tUplus';
      $size = 1;
      $data = '+';
      break;
    case 0x13:
      $name = 'tUminus';
      $size = 1;
      $data = '-';
      break;
    case 0x14:
      $name = 'tPercent';
      $size = 1;
      $data = '%';
      break;
    case 0x15:

      //	parenthesis
      $name = 'tParen';
      $size = 1;
      $data = null;
      break;
    case 0x16:

      //	missing argument
      $name = 'tMissArg';
      $size = 1;
      $data = '';
      break;
    case 0x17:

      //	string
      $name = 'tStr';

      // offset: 1; size: var; Unicode string, 8-bit string length
      $string = self::_readUnicodeStringShort(substr($formulaData, 1));
      $size = 1 + $string['size'];
      $data = self::_UTF8toExcelDoubleQuoted($string['value']);
      break;
    case 0x19:

      //	Special attribute
      // offset: 1; size: 1; attribute type flags:
      switch (ord($formulaData[1])) {
        case 0x1:
          $name = 'tAttrVolatile';
          $size = 4;
          $data = null;
          break;
        case 0x2:
          $name = 'tAttrIf';
          $size = 4;
          $data = null;
          break;
        case 0x4:
          $name = 'tAttrChoose';

          // offset: 2; size: 2; number of choices in the CHOOSE function ($nc, number of parameters decreased by 1)
          $nc = self::_GetInt2d($formulaData, 2);

          // offset: 4; size: 2 * $nc
          // offset: 4 + 2 * $nc; size: 2
          $size = 2 * $nc + 6;
          $data = null;
          break;
        case 0x8:
          $name = 'tAttrSkip';
          $size = 4;
          $data = null;
          break;
        case 0x10:
          $name = 'tAttrSum';
          $size = 4;
          $data = null;
          break;
        case 0x40:
        case 0x41:
          $name = 'tAttrSpace';
          $size = 4;

          // offset: 2; size: 2; space type and position
          switch (ord($formulaData[2])) {
            case 0x0:
              $spacetype = 'type0';
              break;
            case 0x1:
              $spacetype = 'type1';
              break;
            case 0x2:
              $spacetype = 'type2';
              break;
            case 0x3:
              $spacetype = 'type3';
              break;
            case 0x4:
              $spacetype = 'type4';
              break;
            case 0x5:
              $spacetype = 'type5';
              break;
            default:
              throw new PHPExcel_Reader_Exception('Unrecognized space type in tAttrSpace token');
              break;
          }

          // offset: 3; size: 1; number of inserted spaces/carriage returns
          $spacecount = ord($formulaData[3]);
          $data = array(
            'spacetype' => $spacetype,
            'spacecount' => $spacecount,
          );
          break;
        default:
          throw new PHPExcel_Reader_Exception('Unrecognized attribute flag in tAttr token');
          break;
      }
      break;
    case 0x1c:

      //	error code
      // offset: 1; size: 1; error code
      $name = 'tErr';
      $size = 2;
      $data = self::_mapErrorCode(ord($formulaData[1]));
      break;
    case 0x1d:

      //	boolean
      // offset: 1; size: 1; 0 = false, 1 = true;
      $name = 'tBool';
      $size = 2;
      $data = ord($formulaData[1]) ? 'TRUE' : 'FALSE';
      break;
    case 0x1e:

      //	integer
      // offset: 1; size: 2; unsigned 16-bit integer
      $name = 'tInt';
      $size = 3;
      $data = self::_GetInt2d($formulaData, 1);
      break;
    case 0x1f:

      //	number
      // offset: 1; size: 8;
      $name = 'tNum';
      $size = 9;
      $data = self::_extractNumber(substr($formulaData, 1));
      $data = str_replace(',', '.', (string) $data);

      // in case non-English locale
      break;
    case 0x20:

    //	array constant
    case 0x40:
    case 0x60:

      // offset: 1; size: 7; not used
      $name = 'tArray';
      $size = 8;
      $data = null;
      break;
    case 0x21:

    //	function with fixed number of arguments
    case 0x41:
    case 0x61:
      $name = 'tFunc';
      $size = 3;

      // offset: 1; size: 2; index to built-in sheet function
      switch (self::_GetInt2d($formulaData, 1)) {
        case 2:
          $function = 'ISNA';
          $args = 1;
          break;
        case 3:
          $function = 'ISERROR';
          $args = 1;
          break;
        case 10:
          $function = 'NA';
          $args = 0;
          break;
        case 15:
          $function = 'SIN';
          $args = 1;
          break;
        case 16:
          $function = 'COS';
          $args = 1;
          break;
        case 17:
          $function = 'TAN';
          $args = 1;
          break;
        case 18:
          $function = 'ATAN';
          $args = 1;
          break;
        case 19:
          $function = 'PI';
          $args = 0;
          break;
        case 20:
          $function = 'SQRT';
          $args = 1;
          break;
        case 21:
          $function = 'EXP';
          $args = 1;
          break;
        case 22:
          $function = 'LN';
          $args = 1;
          break;
        case 23:
          $function = 'LOG10';
          $args = 1;
          break;
        case 24:
          $function = 'ABS';
          $args = 1;
          break;
        case 25:
          $function = 'INT';
          $args = 1;
          break;
        case 26:
          $function = 'SIGN';
          $args = 1;
          break;
        case 27:
          $function = 'ROUND';
          $args = 2;
          break;
        case 30:
          $function = 'REPT';
          $args = 2;
          break;
        case 31:
          $function = 'MID';
          $args = 3;
          break;
        case 32:
          $function = 'LEN';
          $args = 1;
          break;
        case 33:
          $function = 'VALUE';
          $args = 1;
          break;
        case 34:
          $function = 'TRUE';
          $args = 0;
          break;
        case 35:
          $function = 'FALSE';
          $args = 0;
          break;
        case 38:
          $function = 'NOT';
          $args = 1;
          break;
        case 39:
          $function = 'MOD';
          $args = 2;
          break;
        case 40:
          $function = 'DCOUNT';
          $args = 3;
          break;
        case 41:
          $function = 'DSUM';
          $args = 3;
          break;
        case 42:
          $function = 'DAVERAGE';
          $args = 3;
          break;
        case 43:
          $function = 'DMIN';
          $args = 3;
          break;
        case 44:
          $function = 'DMAX';
          $args = 3;
          break;
        case 45:
          $function = 'DSTDEV';
          $args = 3;
          break;
        case 48:
          $function = 'TEXT';
          $args = 2;
          break;
        case 61:
          $function = 'MIRR';
          $args = 3;
          break;
        case 63:
          $function = 'RAND';
          $args = 0;
          break;
        case 65:
          $function = 'DATE';
          $args = 3;
          break;
        case 66:
          $function = 'TIME';
          $args = 3;
          break;
        case 67:
          $function = 'DAY';
          $args = 1;
          break;
        case 68:
          $function = 'MONTH';
          $args = 1;
          break;
        case 69:
          $function = 'YEAR';
          $args = 1;
          break;
        case 71:
          $function = 'HOUR';
          $args = 1;
          break;
        case 72:
          $function = 'MINUTE';
          $args = 1;
          break;
        case 73:
          $function = 'SECOND';
          $args = 1;
          break;
        case 74:
          $function = 'NOW';
          $args = 0;
          break;
        case 75:
          $function = 'AREAS';
          $args = 1;
          break;
        case 76:
          $function = 'ROWS';
          $args = 1;
          break;
        case 77:
          $function = 'COLUMNS';
          $args = 1;
          break;
        case 83:
          $function = 'TRANSPOSE';
          $args = 1;
          break;
        case 86:
          $function = 'TYPE';
          $args = 1;
          break;
        case 97:
          $function = 'ATAN2';
          $args = 2;
          break;
        case 98:
          $function = 'ASIN';
          $args = 1;
          break;
        case 99:
          $function = 'ACOS';
          $args = 1;
          break;
        case 105:
          $function = 'ISREF';
          $args = 1;
          break;
        case 111:
          $function = 'CHAR';
          $args = 1;
          break;
        case 112:
          $function = 'LOWER';
          $args = 1;
          break;
        case 113:
          $function = 'UPPER';
          $args = 1;
          break;
        case 114:
          $function = 'PROPER';
          $args = 1;
          break;
        case 117:
          $function = 'EXACT';
          $args = 2;
          break;
        case 118:
          $function = 'TRIM';
          $args = 1;
          break;
        case 119:
          $function = 'REPLACE';
          $args = 4;
          break;
        case 121:
          $function = 'CODE';
          $args = 1;
          break;
        case 126:
          $function = 'ISERR';
          $args = 1;
          break;
        case 127:
          $function = 'ISTEXT';
          $args = 1;
          break;
        case 128:
          $function = 'ISNUMBER';
          $args = 1;
          break;
        case 129:
          $function = 'ISBLANK';
          $args = 1;
          break;
        case 130:
          $function = 'T';
          $args = 1;
          break;
        case 131:
          $function = 'N';
          $args = 1;
          break;
        case 140:
          $function = 'DATEVALUE';
          $args = 1;
          break;
        case 141:
          $function = 'TIMEVALUE';
          $args = 1;
          break;
        case 142:
          $function = 'SLN';
          $args = 3;
          break;
        case 143:
          $function = 'SYD';
          $args = 4;
          break;
        case 162:
          $function = 'CLEAN';
          $args = 1;
          break;
        case 163:
          $function = 'MDETERM';
          $args = 1;
          break;
        case 164:
          $function = 'MINVERSE';
          $args = 1;
          break;
        case 165:
          $function = 'MMULT';
          $args = 2;
          break;
        case 184:
          $function = 'FACT';
          $args = 1;
          break;
        case 189:
          $function = 'DPRODUCT';
          $args = 3;
          break;
        case 190:
          $function = 'ISNONTEXT';
          $args = 1;
          break;
        case 195:
          $function = 'DSTDEVP';
          $args = 3;
          break;
        case 196:
          $function = 'DVARP';
          $args = 3;
          break;
        case 198:
          $function = 'ISLOGICAL';
          $args = 1;
          break;
        case 199:
          $function = 'DCOUNTA';
          $args = 3;
          break;
        case 207:
          $function = 'REPLACEB';
          $args = 4;
          break;
        case 210:
          $function = 'MIDB';
          $args = 3;
          break;
        case 211:
          $function = 'LENB';
          $args = 1;
          break;
        case 212:
          $function = 'ROUNDUP';
          $args = 2;
          break;
        case 213:
          $function = 'ROUNDDOWN';
          $args = 2;
          break;
        case 214:
          $function = 'ASC';
          $args = 1;
          break;
        case 215:
          $function = 'DBCS';
          $args = 1;
          break;
        case 221:
          $function = 'TODAY';
          $args = 0;
          break;
        case 229:
          $function = 'SINH';
          $args = 1;
          break;
        case 230:
          $function = 'COSH';
          $args = 1;
          break;
        case 231:
          $function = 'TANH';
          $args = 1;
          break;
        case 232:
          $function = 'ASINH';
          $args = 1;
          break;
        case 233:
          $function = 'ACOSH';
          $args = 1;
          break;
        case 234:
          $function = 'ATANH';
          $args = 1;
          break;
        case 235:
          $function = 'DGET';
          $args = 3;
          break;
        case 244:
          $function = 'INFO';
          $args = 1;
          break;
        case 252:
          $function = 'FREQUENCY';
          $args = 2;
          break;
        case 261:
          $function = 'ERROR.TYPE';
          $args = 1;
          break;
        case 271:
          $function = 'GAMMALN';
          $args = 1;
          break;
        case 273:
          $function = 'BINOMDIST';
          $args = 4;
          break;
        case 274:
          $function = 'CHIDIST';
          $args = 2;
          break;
        case 275:
          $function = 'CHIINV';
          $args = 2;
          break;
        case 276:
          $function = 'COMBIN';
          $args = 2;
          break;
        case 277:
          $function = 'CONFIDENCE';
          $args = 3;
          break;
        case 278:
          $function = 'CRITBINOM';
          $args = 3;
          break;
        case 279:
          $function = 'EVEN';
          $args = 1;
          break;
        case 280:
          $function = 'EXPONDIST';
          $args = 3;
          break;
        case 281:
          $function = 'FDIST';
          $args = 3;
          break;
        case 282:
          $function = 'FINV';
          $args = 3;
          break;
        case 283:
          $function = 'FISHER';
          $args = 1;
          break;
        case 284:
          $function = 'FISHERINV';
          $args = 1;
          break;
        case 285:
          $function = 'FLOOR';
          $args = 2;
          break;
        case 286:
          $function = 'GAMMADIST';
          $args = 4;
          break;
        case 287:
          $function = 'GAMMAINV';
          $args = 3;
          break;
        case 288:
          $function = 'CEILING';
          $args = 2;
          break;
        case 289:
          $function = 'HYPGEOMDIST';
          $args = 4;
          break;
        case 290:
          $function = 'LOGNORMDIST';
          $args = 3;
          break;
        case 291:
          $function = 'LOGINV';
          $args = 3;
          break;
        case 292:
          $function = 'NEGBINOMDIST';
          $args = 3;
          break;
        case 293:
          $function = 'NORMDIST';
          $args = 4;
          break;
        case 294:
          $function = 'NORMSDIST';
          $args = 1;
          break;
        case 295:
          $function = 'NORMINV';
          $args = 3;
          break;
        case 296:
          $function = 'NORMSINV';
          $args = 1;
          break;
        case 297:
          $function = 'STANDARDIZE';
          $args = 3;
          break;
        case 298:
          $function = 'ODD';
          $args = 1;
          break;
        case 299:
          $function = 'PERMUT';
          $args = 2;
          break;
        case 300:
          $function = 'POISSON';
          $args = 3;
          break;
        case 301:
          $function = 'TDIST';
          $args = 3;
          break;
        case 302:
          $function = 'WEIBULL';
          $args = 4;
          break;
        case 303:
          $function = 'SUMXMY2';
          $args = 2;
          break;
        case 304:
          $function = 'SUMX2MY2';
          $args = 2;
          break;
        case 305:
          $function = 'SUMX2PY2';
          $args = 2;
          break;
        case 306:
          $function = 'CHITEST';
          $args = 2;
          break;
        case 307:
          $function = 'CORREL';
          $args = 2;
          break;
        case 308:
          $function = 'COVAR';
          $args = 2;
          break;
        case 309:
          $function = 'FORECAST';
          $args = 3;
          break;
        case 310:
          $function = 'FTEST';
          $args = 2;
          break;
        case 311:
          $function = 'INTERCEPT';
          $args = 2;
          break;
        case 312:
          $function = 'PEARSON';
          $args = 2;
          break;
        case 313:
          $function = 'RSQ';
          $args = 2;
          break;
        case 314:
          $function = 'STEYX';
          $args = 2;
          break;
        case 315:
          $function = 'SLOPE';
          $args = 2;
          break;
        case 316:
          $function = 'TTEST';
          $args = 4;
          break;
        case 325:
          $function = 'LARGE';
          $args = 2;
          break;
        case 326:
          $function = 'SMALL';
          $args = 2;
          break;
        case 327:
          $function = 'QUARTILE';
          $args = 2;
          break;
        case 328:
          $function = 'PERCENTILE';
          $args = 2;
          break;
        case 331:
          $function = 'TRIMMEAN';
          $args = 2;
          break;
        case 332:
          $function = 'TINV';
          $args = 2;
          break;
        case 337:
          $function = 'POWER';
          $args = 2;
          break;
        case 342:
          $function = 'RADIANS';
          $args = 1;
          break;
        case 343:
          $function = 'DEGREES';
          $args = 1;
          break;
        case 346:
          $function = 'COUNTIF';
          $args = 2;
          break;
        case 347:
          $function = 'COUNTBLANK';
          $args = 1;
          break;
        case 350:
          $function = 'ISPMT';
          $args = 4;
          break;
        case 351:
          $function = 'DATEDIF';
          $args = 3;
          break;
        case 352:
          $function = 'DATESTRING';
          $args = 1;
          break;
        case 353:
          $function = 'NUMBERSTRING';
          $args = 2;
          break;
        case 360:
          $function = 'PHONETIC';
          $args = 1;
          break;
        case 368:
          $function = 'BAHTTEXT';
          $args = 1;
          break;
        default:
          throw new PHPExcel_Reader_Exception('Unrecognized function in formula');
          break;
      }
      $data = array(
        'function' => $function,
        'args' => $args,
      );
      break;
    case 0x22:

    //	function with variable number of arguments
    case 0x42:
    case 0x62:
      $name = 'tFuncV';
      $size = 4;

      // offset: 1; size: 1; number of arguments
      $args = ord($formulaData[1]);

      // offset: 2: size: 2; index to built-in sheet function
      $index = self::_GetInt2d($formulaData, 2);
      switch ($index) {
        case 0:
          $function = 'COUNT';
          break;
        case 1:
          $function = 'IF';
          break;
        case 4:
          $function = 'SUM';
          break;
        case 5:
          $function = 'AVERAGE';
          break;
        case 6:
          $function = 'MIN';
          break;
        case 7:
          $function = 'MAX';
          break;
        case 8:
          $function = 'ROW';
          break;
        case 9:
          $function = 'COLUMN';
          break;
        case 11:
          $function = 'NPV';
          break;
        case 12:
          $function = 'STDEV';
          break;
        case 13:
          $function = 'DOLLAR';
          break;
        case 14:
          $function = 'FIXED';
          break;
        case 28:
          $function = 'LOOKUP';
          break;
        case 29:
          $function = 'INDEX';
          break;
        case 36:
          $function = 'AND';
          break;
        case 37:
          $function = 'OR';
          break;
        case 46:
          $function = 'VAR';
          break;
        case 49:
          $function = 'LINEST';
          break;
        case 50:
          $function = 'TREND';
          break;
        case 51:
          $function = 'LOGEST';
          break;
        case 52:
          $function = 'GROWTH';
          break;
        case 56:
          $function = 'PV';
          break;
        case 57:
          $function = 'FV';
          break;
        case 58:
          $function = 'NPER';
          break;
        case 59:
          $function = 'PMT';
          break;
        case 60:
          $function = 'RATE';
          break;
        case 62:
          $function = 'IRR';
          break;
        case 64:
          $function = 'MATCH';
          break;
        case 70:
          $function = 'WEEKDAY';
          break;
        case 78:
          $function = 'OFFSET';
          break;
        case 82:
          $function = 'SEARCH';
          break;
        case 100:
          $function = 'CHOOSE';
          break;
        case 101:
          $function = 'HLOOKUP';
          break;
        case 102:
          $function = 'VLOOKUP';
          break;
        case 109:
          $function = 'LOG';
          break;
        case 115:
          $function = 'LEFT';
          break;
        case 116:
          $function = 'RIGHT';
          break;
        case 120:
          $function = 'SUBSTITUTE';
          break;
        case 124:
          $function = 'FIND';
          break;
        case 125:
          $function = 'CELL';
          break;
        case 144:
          $function = 'DDB';
          break;
        case 148:
          $function = 'INDIRECT';
          break;
        case 167:
          $function = 'IPMT';
          break;
        case 168:
          $function = 'PPMT';
          break;
        case 169:
          $function = 'COUNTA';
          break;
        case 183:
          $function = 'PRODUCT';
          break;
        case 193:
          $function = 'STDEVP';
          break;
        case 194:
          $function = 'VARP';
          break;
        case 197:
          $function = 'TRUNC';
          break;
        case 204:
          $function = 'USDOLLAR';
          break;
        case 205:
          $function = 'FINDB';
          break;
        case 206:
          $function = 'SEARCHB';
          break;
        case 208:
          $function = 'LEFTB';
          break;
        case 209:
          $function = 'RIGHTB';
          break;
        case 216:
          $function = 'RANK';
          break;
        case 219:
          $function = 'ADDRESS';
          break;
        case 220:
          $function = 'DAYS360';
          break;
        case 222:
          $function = 'VDB';
          break;
        case 227:
          $function = 'MEDIAN';
          break;
        case 228:
          $function = 'SUMPRODUCT';
          break;
        case 247:
          $function = 'DB';
          break;
        case 255:
          $function = '';
          break;
        case 269:
          $function = 'AVEDEV';
          break;
        case 270:
          $function = 'BETADIST';
          break;
        case 272:
          $function = 'BETAINV';
          break;
        case 317:
          $function = 'PROB';
          break;
        case 318:
          $function = 'DEVSQ';
          break;
        case 319:
          $function = 'GEOMEAN';
          break;
        case 320:
          $function = 'HARMEAN';
          break;
        case 321:
          $function = 'SUMSQ';
          break;
        case 322:
          $function = 'KURT';
          break;
        case 323:
          $function = 'SKEW';
          break;
        case 324:
          $function = 'ZTEST';
          break;
        case 329:
          $function = 'PERCENTRANK';
          break;
        case 330:
          $function = 'MODE';
          break;
        case 336:
          $function = 'CONCATENATE';
          break;
        case 344:
          $function = 'SUBTOTAL';
          break;
        case 345:
          $function = 'SUMIF';
          break;
        case 354:
          $function = 'ROMAN';
          break;
        case 358:
          $function = 'GETPIVOTDATA';
          break;
        case 359:
          $function = 'HYPERLINK';
          break;
        case 361:
          $function = 'AVERAGEA';
          break;
        case 362:
          $function = 'MAXA';
          break;
        case 363:
          $function = 'MINA';
          break;
        case 364:
          $function = 'STDEVPA';
          break;
        case 365:
          $function = 'VARPA';
          break;
        case 366:
          $function = 'STDEVA';
          break;
        case 367:
          $function = 'VARA';
          break;
        default:
          throw new PHPExcel_Reader_Exception('Unrecognized function in formula');
          break;
      }
      $data = array(
        'function' => $function,
        'args' => $args,
      );
      break;
    case 0x23:

    //	index to defined name
    case 0x43:
    case 0x63:
      $name = 'tName';
      $size = 5;

      // offset: 1; size: 2; one-based index to definedname record
      $definedNameIndex = self::_GetInt2d($formulaData, 1) - 1;

      // offset: 2; size: 2; not used
      $data = $this->_definedname[$definedNameIndex]['name'];
      break;
    case 0x24:

    //	single cell reference e.g. A5
    case 0x44:
    case 0x64:
      $name = 'tRef';
      $size = 5;
      $data = $this
        ->_readBIFF8CellAddress(substr($formulaData, 1, 4));
      break;
    case 0x25:

    //	cell range reference to cells in the same sheet (2d)
    case 0x45:
    case 0x65:
      $name = 'tArea';
      $size = 9;
      $data = $this
        ->_readBIFF8CellRangeAddress(substr($formulaData, 1, 8));
      break;
    case 0x26:

    //	Constant reference sub-expression
    case 0x46:
    case 0x66:
      $name = 'tMemArea';

      // offset: 1; size: 4; not used
      // offset: 5; size: 2; size of the following subexpression
      $subSize = self::_GetInt2d($formulaData, 5);
      $size = 7 + $subSize;
      $data = $this
        ->_getFormulaFromData(substr($formulaData, 7, $subSize));
      break;
    case 0x27:

    //	Deleted constant reference sub-expression
    case 0x47:
    case 0x67:
      $name = 'tMemErr';

      // offset: 1; size: 4; not used
      // offset: 5; size: 2; size of the following subexpression
      $subSize = self::_GetInt2d($formulaData, 5);
      $size = 7 + $subSize;
      $data = $this
        ->_getFormulaFromData(substr($formulaData, 7, $subSize));
      break;
    case 0x29:

    //	Variable reference sub-expression
    case 0x49:
    case 0x69:
      $name = 'tMemFunc';

      // offset: 1; size: 2; size of the following sub-expression
      $subSize = self::_GetInt2d($formulaData, 1);
      $size = 3 + $subSize;
      $data = $this
        ->_getFormulaFromData(substr($formulaData, 3, $subSize));
      break;
    case 0x2c:

    // Relative 2d cell reference reference, used in shared formulas and some other places
    case 0x4c:
    case 0x6c:
      $name = 'tRefN';
      $size = 5;
      $data = $this
        ->_readBIFF8CellAddressB(substr($formulaData, 1, 4), $baseCell);
      break;
    case 0x2d:

    //	Relative 2d range reference
    case 0x4d:
    case 0x6d:
      $name = 'tAreaN';
      $size = 9;
      $data = $this
        ->_readBIFF8CellRangeAddressB(substr($formulaData, 1, 8), $baseCell);
      break;
    case 0x39:

    //	External name
    case 0x59:
    case 0x79:
      $name = 'tNameX';
      $size = 7;

      // offset: 1; size: 2; index to REF entry in EXTERNSHEET record
      // offset: 3; size: 2; one-based index to DEFINEDNAME or EXTERNNAME record
      $index = self::_GetInt2d($formulaData, 3);

      // assume index is to EXTERNNAME record
      $data = $this->_externalNames[$index - 1]['name'];

      // offset: 5; size: 2; not used
      break;
    case 0x3a:

    //	3d reference to cell
    case 0x5a:
    case 0x7a:
      $name = 'tRef3d';
      $size = 7;
      try {

        // offset: 1; size: 2; index to REF entry
        $sheetRange = $this
          ->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1));

        // offset: 3; size: 4; cell address
        $cellAddress = $this
          ->_readBIFF8CellAddress(substr($formulaData, 3, 4));
        $data = "{$sheetRange}!{$cellAddress}";
      } catch (PHPExcel_Exception $e) {

        // deleted sheet reference
        $data = '#REF!';
      }
      break;
    case 0x3b:

    //	3d reference to cell range
    case 0x5b:
    case 0x7b:
      $name = 'tArea3d';
      $size = 11;
      try {

        // offset: 1; size: 2; index to REF entry
        $sheetRange = $this
          ->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1));

        // offset: 3; size: 8; cell address
        $cellRangeAddress = $this
          ->_readBIFF8CellRangeAddress(substr($formulaData, 3, 8));
        $data = "{$sheetRange}!{$cellRangeAddress}";
      } catch (PHPExcel_Exception $e) {

        // deleted sheet reference
        $data = '#REF!';
      }
      break;

    // Unknown cases	// don't know how to deal with
    default:
      throw new PHPExcel_Reader_Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula');
      break;
  }
  return array(
    'id' => $id,
    'name' => $name,
    'size' => $size,
    'data' => $data,
  );
}