Workitem 7895 - Excel5 : Formula : Error Constant
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@59926 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
ab9d03069d
commit
4e8a57e369
|
@ -556,6 +556,10 @@ class PHPExcel_Writer_Excel5_Parser
|
||||||
} elseif (isset($this->ptg[$token])) {
|
} elseif (isset($this->ptg[$token])) {
|
||||||
return pack("C", $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().
|
// commented so argument number can be processed correctly. See toReversePolish().
|
||||||
/*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/",$token))
|
/*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/",$token))
|
||||||
{
|
{
|
||||||
|
@ -566,6 +570,7 @@ class PHPExcel_Writer_Excel5_Parser
|
||||||
} elseif ($token == 'arg') {
|
} elseif ($token == 'arg') {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use real error codes
|
// TODO: use real error codes
|
||||||
throw new Exception("Unknown token $token");
|
throw new Exception("Unknown token $token");
|
||||||
}
|
}
|
||||||
|
@ -791,6 +796,26 @@ class PHPExcel_Writer_Excel5_Parser
|
||||||
return $ptgRef . $ext_ref. $row . $col;
|
return $ptgRef . $ext_ref. $row . $col;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an error code to a ptgErr
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param mixed $num an error codefor conversion to its ptg value
|
||||||
|
*/
|
||||||
|
function _convertError($errorCode)
|
||||||
|
{
|
||||||
|
switch ($errorCode) {
|
||||||
|
case '#NULL!': return pack("C", 0x00);
|
||||||
|
case '#DIV/0!': return pack("C", 0x07);
|
||||||
|
case '#VALUE!': return pack("C", 0x0F);
|
||||||
|
case '#REF!': return pack("C", 0x17);
|
||||||
|
case '#NAME?': return pack("C", 0x1D);
|
||||||
|
case '#NUM!': return pack("C", 0x24);
|
||||||
|
case '#N/A': return pack("C", 0x2A);
|
||||||
|
}
|
||||||
|
return pack("C", 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the sheet name part of an external reference, for example "Sheet1" or
|
* Convert the sheet name part of an external reference, for example "Sheet1" or
|
||||||
* "Sheet1:Sheet2", to a packed structure.
|
* "Sheet1:Sheet2", to a packed structure.
|
||||||
|
@ -1207,6 +1232,11 @@ class PHPExcel_Writer_Excel5_Parser
|
||||||
{
|
{
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
|
// If it's an error code
|
||||||
|
elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A')
|
||||||
|
{
|
||||||
|
return $token;
|
||||||
|
}
|
||||||
// if it's a function call
|
// if it's a function call
|
||||||
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "("))
|
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "("))
|
||||||
{
|
{
|
||||||
|
@ -1280,7 +1310,9 @@ class PHPExcel_Writer_Excel5_Parser
|
||||||
* It parses a expression. It assumes the following rule:
|
* It parses a expression. It assumes the following rule:
|
||||||
* Expr -> Term [("+" | "-") Term]
|
* Expr -> Term [("+" | "-") Term]
|
||||||
* -> "string"
|
* -> "string"
|
||||||
* -> "-" Term
|
* -> "-" Term : Negative value
|
||||||
|
* -> "+" Term : Positive value
|
||||||
|
* -> Error code
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @return mixed The parsed ptg'd tree on success
|
* @return mixed The parsed ptg'd tree on success
|
||||||
|
@ -1292,12 +1324,19 @@ class PHPExcel_Writer_Excel5_Parser
|
||||||
$result = $this->_createTree($this->_current_token, '', '');
|
$result = $this->_createTree($this->_current_token, '', '');
|
||||||
$this->_advance();
|
$this->_advance();
|
||||||
return $result;
|
return $result;
|
||||||
} elseif ($this->_current_token == "-") {
|
// If it's an error code
|
||||||
|
} elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $this->_current_token) or $this->_current_token == '#N/A'){
|
||||||
|
$result = $this->_createTree($this->_current_token, 'ptgErr', '');
|
||||||
|
$this->_advance();
|
||||||
|
return $result;
|
||||||
|
// If it's a negative value
|
||||||
|
} elseif ($this->_current_token == "-") {
|
||||||
// catch "-" Term
|
// catch "-" Term
|
||||||
$this->_advance();
|
$this->_advance();
|
||||||
$result2 = $this->_expression();
|
$result2 = $this->_expression();
|
||||||
$result = $this->_createTree('ptgUminus', $result2, '');
|
$result = $this->_createTree('ptgUminus', $result2, '');
|
||||||
return $result;
|
return $result;
|
||||||
|
// If it's a positive value
|
||||||
} elseif ($this->_current_token == "+") {
|
} elseif ($this->_current_token == "+") {
|
||||||
// catch "+" Term
|
// catch "+" Term
|
||||||
$this->_advance();
|
$this->_advance();
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
|
|
||||||
Fixed in SVN:
|
Fixed in SVN:
|
||||||
|
- Bugfix: (Progi1984) Workitem 7895 - Excel5 : Formula : Error constant
|
||||||
- Bugfix: (Progi1984) Workitem 7895 - Excel5 : Formula : Concatenation operator
|
- Bugfix: (Progi1984) Workitem 7895 - Excel5 : Formula : Concatenation operator
|
||||||
|
|
||||||
2010-08-26 (v1.7.4):
|
2010-08-26 (v1.7.4):
|
||||||
|
|
Loading…
Reference in New Issue