Fix for quoted worksheet names in INDIRECT and OFFSET methods; and Docblock fixes

This commit is contained in:
Mark Baker 2013-04-29 22:47:36 +01:00
parent b8c462f1c2
commit 73d2757728
4 changed files with 38 additions and 23 deletions

View File

@ -56,6 +56,18 @@ class PHPExcel_Calculation_DateTime {
} // function _isLeapYear()
/**
* Return the number of days between two dates based on a 360 day calendar
*
* @param integer $startDay Day of month of the start date
* @param integer $startMonth Month of the start date
* @param integer $startYear Year of the start date
* @param integer $endDay Day of month of the start date
* @param integer $endMonth Month of the start date
* @param integer $endYear Year of the start date
* @param boolean $methodUS Whether to use the US method or the European method of calculation
* @return integer Number of days between the start date and the end date
*/
private static function _dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS) {
if ($startDay == 31) {
--$startDay;

View File

@ -741,8 +741,6 @@ class PHPExcel_Calculation_Engineering {
/**
* _cleanComplex
*
* Cleans the leading characters in a complex number string
*
* @param string $complexNumber The complex number to clean
@ -756,7 +754,13 @@ class PHPExcel_Calculation_Engineering {
return $complexNumber;
}
/**
* Formats a number base string value with leading zeroes
*
* @param string $xVal The "number" to pad
* @param integer $places The length that we want to pad this value
* @return string The padded "number"
*/
private static function _nbrConversionFormat($xVal, $places) {
if (!is_null($places)) {
if (strlen($xVal) <= $places) {
@ -769,7 +773,6 @@ class PHPExcel_Calculation_Engineering {
return substr($xVal, -10);
} // function _nbrConversionFormat()
/**
* BESSELI
*

View File

@ -1523,14 +1523,11 @@ class PHPExcel_Calculation_Financial {
}
} // function NPER()
/**
* NPV
*
* Returns the Net Present Value of a cash flow series given a discount rate.
*
* @param float Discount interest rate
* @param array Cash flow series
* @return float
*/
public static function NPV() {
@ -1553,7 +1550,6 @@ class PHPExcel_Calculation_Financial {
return $returnValue;
} // function NPV()
/**
* PMT
*

View File

@ -253,6 +253,7 @@ class PHPExcel_Calculation_LookupRef {
* @category Logical Functions
* @param string $linkURL Value to check, is also the value returned when no error
* @param string $displayName Value to return when testValue is an error condition
* @param PHPExcel_Cell $pCell The cell to set the hyperlink in
* @return mixed The value of $displayName (or $linkURL if $displayName was blank)
*/
public static function HYPERLINK($linkURL = '', $displayName = null, PHPExcel_Cell $pCell = null) {
@ -287,13 +288,14 @@ class PHPExcel_Calculation_LookupRef {
*
* NOTE - INDIRECT() does not yet support the optional a1 parameter introduced in Excel 2010
*
* @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows
* @param cellAddress $cellAddress The cell address of the current cell (containing this formula)
* @param PHPExcel_Cell $pCell The current cell (containing this formula)
* @return mixed The cells referenced by cellAddress
*
* @todo Support for the optional a1 parameter introduced in Excel 2010
*
*/
public static function INDIRECT($cellAddress=Null, PHPExcel_Cell $pCell = null) {
public static function INDIRECT($cellAddress = NULL, PHPExcel_Cell $pCell = NULL) {
$cellAddress = PHPExcel_Calculation_Functions::flattenSingleValue($cellAddress);
if (is_null($cellAddress) || $cellAddress === '') {
return PHPExcel_Calculation_Functions::REF();
@ -307,29 +309,30 @@ class PHPExcel_Calculation_LookupRef {
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) ||
((!is_null($cellAddress2)) && (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress2, $matches)))) {
if (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $cellAddress1, $matches)) {
return PHPExcel_Calculation_Functions::REF();
}
if (strpos($cellAddress,'!') !== false) {
if (strpos($cellAddress,'!') !== FALSE) {
list($sheetName, $cellAddress) = explode('!',$cellAddress);
$sheetName = trim($sheetName, "'");
$pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName);
} else {
$pSheet = $pCell->getParent();
}
return PHPExcel_Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, False);
return PHPExcel_Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, FALSE);
}
if (strpos($cellAddress,'!') !== false) {
if (strpos($cellAddress,'!') !== FALSE) {
list($sheetName,$cellAddress) = explode('!',$cellAddress);
$sheetName = trim($sheetName, "'");
$pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName);
} else {
$pSheet = $pCell->getParent();
}
return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, False);
return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, FALSE);
} // function INDIRECT()
@ -373,9 +376,10 @@ class PHPExcel_Calculation_LookupRef {
return PHPExcel_Calculation_Functions::REF();
}
$sheetName = null;
$sheetName = NULL;
if (strpos($cellAddress,"!")) {
list($sheetName,$cellAddress) = explode("!",$cellAddress);
$sheetName = trim($sheetName, "'");
}
if (strpos($cellAddress,":")) {
list($startCell,$endCell) = explode(":",$cellAddress);
@ -416,7 +420,7 @@ class PHPExcel_Calculation_LookupRef {
$cellAddress .= ':'.$endCellColumn.$endCellRow;
}
if ($sheetName !== null) {
if ($sheetName !== NULL) {
$pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName);
} else {
$pSheet = $pCell->getParent();