You are here

function PHPExcel_Writer_Excel5_Parser::_convert in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php \PHPExcel_Writer_Excel5_Parser::_convert()

* Convert a token to the proper ptg value. * * @access private *

Parameters

mixed $token The token to convert.: * @return mixed the converted token on success

1 call to PHPExcel_Writer_Excel5_Parser::_convert()
PHPExcel_Writer_Excel5_Parser::toReversePolish in vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php
* Builds a string containing the tree in reverse polish notation (What you * would use in a HP calculator stack). * The following tree: * * + * / \ * 2 3 * * produces: "23+" * * The following tree: * * + …

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php, line 515

Class

PHPExcel_Writer_Excel5_Parser
PHPExcel_Writer_Excel5_Parser

Code

function _convert($token) {
  if (preg_match("/\"([^\"]|\"\"){0,255}\"/", $token)) {
    return $this
      ->_convertString($token);
  }
  elseif (is_numeric($token)) {
    return $this
      ->_convertNumber($token);

    // match references like A1 or $A$1
  }
  elseif (preg_match('/^\\$?([A-Ia-i]?[A-Za-z])\\$?(\\d+)$/', $token)) {
    return $this
      ->_convertRef2d($token);

    // match external references like Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1
  }
  elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\\!\\\$?[A-Ia-i]?[A-Za-z]\\\$?(\\d+)\$/u", $token)) {
    return $this
      ->_convertRef3d($token);

    // match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1
  }
  elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\\$?[A-Ia-i]?[A-Za-z]\\\$?(\\d+)\$/u", $token)) {
    return $this
      ->_convertRef3d($token);

    // match ranges like A1:B2 or $A$1:$B$2
  }
  elseif (preg_match('/^(\\$)?[A-Ia-i]?[A-Za-z](\\$)?(\\d+)\\:(\\$)?[A-Ia-i]?[A-Za-z](\\$)?(\\d+)$/', $token)) {
    return $this
      ->_convertRange2d($token);

    // match external ranges like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
  }
  elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\\!\\\$?([A-Ia-i]?[A-Za-z])?\\\$?(\\d+)\\:\\\$?([A-Ia-i]?[A-Za-z])?\\\$?(\\d+)\$/u", $token)) {
    return $this
      ->_convertRange3d($token);

    // match external ranges like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
  }
  elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\\$?([A-Ia-i]?[A-Za-z])?\\\$?(\\d+)\\:\\\$?([A-Ia-i]?[A-Za-z])?\\\$?(\\d+)\$/u", $token)) {
    return $this
      ->_convertRange3d($token);

    // operators (including parentheses)
  }
  elseif (isset($this->ptg[$token])) {
    return pack("C", $this->ptg[$token]);

    // match error codes
  }
  elseif (preg_match("/^#[A-Z0\\/]{3,5}[!?]{1}\$/", $token) or $token == '#N/A') {
    return $this
      ->_convertError($token);

    // commented so argument number can be processed correctly. See toReversePolish().

    /*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/",$token))
    		{
    			return($this->_convertFunction($token,$this->_func_args));
    		}*/

    // if it's an argument, ignore the token (the argument remains)
  }
  elseif ($token == 'arg') {
    return '';
  }

  // TODO: use real error codes
  throw new PHPExcel_Writer_Exception("Unknown token {$token}");
}