mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-23 13:56:05 +03:00
Merge branch 'develop_1.7.9' into develop_2.0.0
This commit is contained in:
commit
a7ddcc5e68
@ -3486,6 +3486,13 @@ class PHPExcel_Calculation {
|
|||||||
|
|
||||||
|
|
||||||
private function _validateBinaryOperand($cellID, &$operand, &$stack) {
|
private function _validateBinaryOperand($cellID, &$operand, &$stack) {
|
||||||
|
if (is_array($operand)) {
|
||||||
|
if ((count($operand, COUNT_RECURSIVE) - count($operand)) == 1) {
|
||||||
|
do {
|
||||||
|
$operand = array_pop($operand);
|
||||||
|
} while (is_array($operand));
|
||||||
|
}
|
||||||
|
}
|
||||||
// Numbers, matrices and booleans can pass straight through, as they're already valid
|
// Numbers, matrices and booleans can pass straight through, as they're already valid
|
||||||
if (is_string($operand)) {
|
if (is_string($operand)) {
|
||||||
// We only need special validations for the operand if it is a string
|
// We only need special validations for the operand if it is a string
|
||||||
@ -3591,25 +3598,13 @@ class PHPExcel_Calculation {
|
|||||||
if (!$this->_validateBinaryOperand($cellID,$operand1,$stack)) return FALSE;
|
if (!$this->_validateBinaryOperand($cellID,$operand1,$stack)) return FALSE;
|
||||||
if (!$this->_validateBinaryOperand($cellID,$operand2,$stack)) return FALSE;
|
if (!$this->_validateBinaryOperand($cellID,$operand2,$stack)) return FALSE;
|
||||||
|
|
||||||
$executeMatrixOperation = FALSE;
|
|
||||||
// If either of the operands is a matrix, we need to treat them both as matrices
|
// If either of the operands is a matrix, we need to treat them both as matrices
|
||||||
// (converting the other operand to a matrix if need be); then perform the required
|
// (converting the other operand to a matrix if need be); then perform the required
|
||||||
// matrix operation
|
// matrix operation
|
||||||
if ((is_array($operand1)) || (is_array($operand2))) {
|
if ((is_array($operand1)) || (is_array($operand2))) {
|
||||||
// Ensure that both operands are arrays/matrices
|
// Ensure that both operands are arrays/matrices of the same size
|
||||||
$executeMatrixOperation = TRUE;
|
self::_checkMatrixOperands($operand1, $operand2, 2);
|
||||||
$mSize = array();
|
|
||||||
list($mSize[],$mSize[],$mSize[],$mSize[]) = self::_checkMatrixOperands($operand1,$operand2,2);
|
|
||||||
|
|
||||||
// But if they're both single cell matrices, then we can treat them as simple values
|
|
||||||
if (array_sum($mSize) == 4) {
|
|
||||||
$executeMatrixOperation = FALSE;
|
|
||||||
$operand1 = $operand1[0][0];
|
|
||||||
$operand2 = $operand2[0][0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($executeMatrixOperation) {
|
|
||||||
try {
|
try {
|
||||||
// Convert operand 1 from a PHP array to a matrix
|
// Convert operand 1 from a PHP array to a matrix
|
||||||
$matrix = new PHPExcel_Shared_JAMA_Matrix($operand1);
|
$matrix = new PHPExcel_Shared_JAMA_Matrix($operand1);
|
||||||
|
@ -161,14 +161,15 @@ class PHPExcel_Shared_OLE_ChainedBlockStream
|
|||||||
*/
|
*/
|
||||||
public function stream_eof()
|
public function stream_eof()
|
||||||
{
|
{
|
||||||
$eof = $this->pos >= strlen($this->data);
|
// As we don't support below 5.2 anymore, this is simply redundancy and overhead
|
||||||
// Workaround for bug in PHP 5.0.x: http://bugs.php.net/27508
|
// $eof = $this->pos >= strlen($this->data);
|
||||||
if (version_compare(PHP_VERSION, '5.0', '>=') &&
|
// // Workaround for bug in PHP 5.0.x: http://bugs.php.net/27508
|
||||||
version_compare(PHP_VERSION, '5.1', '<')) {
|
// if (version_compare(PHP_VERSION, '5.0', '>=') &&
|
||||||
|
// version_compare(PHP_VERSION, '5.1', '<')) {
|
||||||
$eof = !$eof;
|
// $eof = !$eof;
|
||||||
}
|
// }
|
||||||
return $eof;
|
// return $eof;
|
||||||
|
return $this->pos >= strlen($this->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -673,7 +673,10 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
|
|||||||
);
|
);
|
||||||
$value = preg_replace($number_regex, $value, $format);
|
$value = preg_replace($number_regex, $value, $format);
|
||||||
} else {
|
} else {
|
||||||
if (preg_match('/0([^\d\.]+)0/', $format, $matches)) {
|
if (preg_match('/0E[+-]0/i', $format)) {
|
||||||
|
// Scientific format
|
||||||
|
$value = sprintf('%5.2E', $value);
|
||||||
|
} elseif (preg_match('/0([^\d\.]+)0/', $format)) {
|
||||||
$value = self::_complexNumberFormatMask($value, $format);
|
$value = self::_complexNumberFormatMask($value, $format);
|
||||||
} else {
|
} else {
|
||||||
$sprintf_pattern = "%0$minWidth." . strlen($right) . "f";
|
$sprintf_pattern = "%0$minWidth." . strlen($right) . "f";
|
||||||
|
@ -1054,7 +1054,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*/
|
*/
|
||||||
public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $returnCell = false)
|
public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $returnCell = false)
|
||||||
{
|
{
|
||||||
$cell = $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValue($pValue);
|
$cell = $this->getCellByColumnAndRow($pColumn, $pRow)->setValue($pValue);
|
||||||
return ($returnCell) ? $cell : $this;
|
return ($returnCell) ? $cell : $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1086,7 +1086,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*/
|
*/
|
||||||
public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, $returnCell = false)
|
public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, $returnCell = false)
|
||||||
{
|
{
|
||||||
$cell = $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValueExplicit($pValue, $pDataType);
|
$cell = $this->getCellByColumnAndRow($pColumn, $pRow)->setValueExplicit($pValue, $pDataType);
|
||||||
return ($returnCell) ? $cell : $this;
|
return ($returnCell) ? $cell : $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1127,37 +1127,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
throw new PHPExcel_Exception('Cell coordinate can not be a range of cells.');
|
throw new PHPExcel_Exception('Cell coordinate can not be a range of cells.');
|
||||||
} elseif (strpos($pCoordinate, '$') !== false) {
|
} elseif (strpos($pCoordinate, '$') !== false) {
|
||||||
throw new PHPExcel_Exception('Cell coordinate must not be absolute.');
|
throw new PHPExcel_Exception('Cell coordinate must not be absolute.');
|
||||||
} else {
|
}
|
||||||
|
|
||||||
// Create new cell object
|
// Create new cell object
|
||||||
|
return $this->_createNewCell($pCoordinate);
|
||||||
// Coordinates
|
|
||||||
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
|
|
||||||
|
|
||||||
$cell = $this->_cellCollection->addCacheData($pCoordinate,new PHPExcel_Cell(NULL, PHPExcel_Cell_DataType::TYPE_NULL, $this));
|
|
||||||
$this->_cellCollectionIsSorted = false;
|
|
||||||
|
|
||||||
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0]))
|
|
||||||
$this->_cachedHighestColumn = $aCoordinates[0];
|
|
||||||
|
|
||||||
$this->_cachedHighestRow = max($this->_cachedHighestRow,$aCoordinates[1]);
|
|
||||||
|
|
||||||
// Cell needs appropriate xfIndex
|
|
||||||
$rowDimensions = $this->getRowDimensions();
|
|
||||||
$columnDimensions = $this->getColumnDimensions();
|
|
||||||
|
|
||||||
if ( isset($rowDimensions[$aCoordinates[1]]) && $rowDimensions[$aCoordinates[1]]->getXfIndex() !== null ) {
|
|
||||||
// then there is a row dimension with explicit style, assign it to the cell
|
|
||||||
$cell->setXfIndex($rowDimensions[$aCoordinates[1]]->getXfIndex());
|
|
||||||
} else if ( isset($columnDimensions[$aCoordinates[0]]) ) {
|
|
||||||
// then there is a column dimension, assign it to the cell
|
|
||||||
$cell->setXfIndex($columnDimensions[$aCoordinates[0]]->getXfIndex());
|
|
||||||
} else {
|
|
||||||
// set to default index
|
|
||||||
$cell->setXfIndex(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $cell;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1172,23 +1145,55 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn);
|
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn);
|
||||||
$coordinate = $columnLetter . $pRow;
|
$coordinate = $columnLetter . $pRow;
|
||||||
|
|
||||||
if (!$this->_cellCollection->isDataSet($coordinate)) {
|
if ($this->_cellCollection->isDataSet($coordinate)) {
|
||||||
$cell = $this->_cellCollection->addCacheData($coordinate, new PHPExcel_Cell(NULL, PHPExcel_Cell_DataType::TYPE_NULL, $this));
|
return $this->_cellCollection->getCacheData($coordinate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_createNewCell($coordinate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new cell at the specified coordinate
|
||||||
|
*
|
||||||
|
* @param string $pCoordinate Coordinate of the cell
|
||||||
|
* @return PHPExcel_Cell Cell that was created
|
||||||
|
*/
|
||||||
|
private function _createNewCell($pCoordinate)
|
||||||
|
{
|
||||||
|
$cell = $this->_cellCollection->addCacheData(
|
||||||
|
$pCoordinate,
|
||||||
|
new PHPExcel_Cell(
|
||||||
|
NULL,
|
||||||
|
PHPExcel_Cell_DataType::TYPE_NULL,
|
||||||
|
$this
|
||||||
|
)
|
||||||
|
);
|
||||||
$this->_cellCollectionIsSorted = false;
|
$this->_cellCollectionIsSorted = false;
|
||||||
|
|
||||||
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < $pColumn)
|
// Coordinates
|
||||||
$this->_cachedHighestColumn = $columnLetter;
|
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
|
||||||
|
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0]))
|
||||||
|
$this->_cachedHighestColumn = $aCoordinates[0];
|
||||||
|
$this->_cachedHighestRow = max($this->_cachedHighestRow, $aCoordinates[1]);
|
||||||
|
|
||||||
$this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow);
|
// Cell needs appropriate xfIndex from dimensions records
|
||||||
|
// but don't create dimension records if they don't already exist
|
||||||
|
$rowDimension = $this->getRowDimension($aCoordinates[1], FALSE);
|
||||||
|
$columnDimension = $this->getColumnDimension($aCoordinates[0], FALSE);
|
||||||
|
|
||||||
|
if ($rowDimension !== NULL && $rowDimension->getXfIndex() > 0) {
|
||||||
|
// then there is a row dimension with explicit style, assign it to the cell
|
||||||
|
$cell->setXfIndex($rowDimension->getXfIndex());
|
||||||
|
} elseif ($columnDimension !== NULL && $columnDimension->getXfIndex() > 0) {
|
||||||
|
// then there is a column dimension, assign it to the cell
|
||||||
|
$cell->setXfIndex($columnDimension->getXfIndex());
|
||||||
|
}
|
||||||
|
|
||||||
return $cell;
|
return $cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_cellCollection->getCacheData($coordinate);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cell at a specific coordinate exists?
|
* Does the cell at a specific coordinate exist?
|
||||||
*
|
*
|
||||||
* @param string $pCoordinate Coordinate of the cell
|
* @param string $pCoordinate Coordinate of the cell
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
@ -1253,13 +1258,15 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @param int $pRow Numeric index of the row
|
* @param int $pRow Numeric index of the row
|
||||||
* @return PHPExcel_Worksheet_RowDimension
|
* @return PHPExcel_Worksheet_RowDimension
|
||||||
*/
|
*/
|
||||||
public function getRowDimension($pRow = 1)
|
public function getRowDimension($pRow = 1, $create = TRUE)
|
||||||
{
|
{
|
||||||
// Found
|
// Found
|
||||||
$found = null;
|
$found = null;
|
||||||
|
|
||||||
// Get row dimension
|
// Get row dimension
|
||||||
if (!isset($this->_rowDimensions[$pRow])) {
|
if (!isset($this->_rowDimensions[$pRow])) {
|
||||||
|
if (!$create)
|
||||||
|
return NULL;
|
||||||
$this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow);
|
$this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow);
|
||||||
|
|
||||||
$this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow);
|
$this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow);
|
||||||
@ -1273,13 +1280,15 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @param string $pColumn String index of the column
|
* @param string $pColumn String index of the column
|
||||||
* @return PHPExcel_Worksheet_ColumnDimension
|
* @return PHPExcel_Worksheet_ColumnDimension
|
||||||
*/
|
*/
|
||||||
public function getColumnDimension($pColumn = 'A')
|
public function getColumnDimension($pColumn = 'A', $create = TRUE)
|
||||||
{
|
{
|
||||||
// Uppercase coordinate
|
// Uppercase coordinate
|
||||||
$pColumn = strtoupper($pColumn);
|
$pColumn = strtoupper($pColumn);
|
||||||
|
|
||||||
// Fetch dimensions
|
// Fetch dimensions
|
||||||
if (!isset($this->_columnDimensions[$pColumn])) {
|
if (!isset($this->_columnDimensions[$pColumn])) {
|
||||||
|
if (!$create)
|
||||||
|
return NULL;
|
||||||
$this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn);
|
$this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn);
|
||||||
|
|
||||||
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn))
|
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn))
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
123.456, '"$#,##0.00"', "$123.46"
|
123.456, '"$#,##0.00"', "$123.46"
|
||||||
|
-123.456, '"$#,##0.00"', "$-123.46"
|
||||||
123.456, '"#,##0.00"', "123.46"
|
123.456, '"#,##0.00"', "123.46"
|
||||||
123.456, '"#,##0"', "123"
|
123.456, '"#,##0"', "123"
|
||||||
123.456, "00000", "00123"
|
123.456, "00000", "00123"
|
||||||
123456.789, '"$#,##0.00"', '"$123,456.79"'
|
123456.789, '"$#,##0.00"', '"$123,456.79"'
|
||||||
123456.789, '"#,##0.00"', '"123,456.79"'
|
123456.789, '"#,##0.00"', '"123,456.79"'
|
||||||
123456.789, "0.00E+00", "1.23E05"
|
123456.789, "0.00E+00", "1.23E05"
|
||||||
|
-123456.789, "0.00E+00", "-1.23E05"
|
||||||
|
0.000012345, "0.00E+00", "1.23E-05"
|
||||||
"19-Dec-1960", "yyyy-mm-dd", "1960-12-19"
|
"19-Dec-1960", "yyyy-mm-dd", "1960-12-19"
|
||||||
"1-Jan-2012", "yyyy-mm-dd", "2012-01-01"
|
"1-Jan-2012", "yyyy-mm-dd", "2012-01-01"
|
||||||
1.75, "# ?/?", "1 3/4"
|
1.75, "# ?/?", "1 3/4"
|
||||||
|
Loading…
Reference in New Issue
Block a user