Search style by identity in PHPExcel_Worksheet::duplicateStyle()
This commit is contained in:
parent
4381f9740c
commit
db2a7cbabf
|
@ -607,6 +607,22 @@ class PHPExcel
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if style exists in style collection
|
||||||
|
*
|
||||||
|
* @param PHPExcel_Style $style
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function cellXfExists($pCellStyle = null)
|
||||||
|
{
|
||||||
|
foreach ($this->_cellXfCollection as $cellXf) {
|
||||||
|
if ($cellXf === $pCellStyle) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get default style
|
* Get default style
|
||||||
*
|
*
|
||||||
|
|
|
@ -1454,9 +1454,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||||
|
|
||||||
// Add the style to the workbook if necessary
|
// Add the style to the workbook if necessary
|
||||||
$workbook = $this->_parent;
|
$workbook = $this->_parent;
|
||||||
if ($existingStyle = $this->_parent->getCellXfByHashCode($pCellStyle->getHashCode())) {
|
if ($this->_parent->cellXfExists($pCellStyle)) {
|
||||||
// there is already such cell Xf in our collection
|
// there is already this cell Xf in our collection
|
||||||
$xfIndex = $existingStyle->getIndex();
|
$xfIndex = $pCellStyle->getIndex();
|
||||||
} else {
|
} else {
|
||||||
// we don't have such a cell Xf, need to add
|
// we don't have such a cell Xf, need to add
|
||||||
$workbook->addCellXf($pCellStyle);
|
$workbook->addCellXf($pCellStyle);
|
||||||
|
|
Loading…
Reference in New Issue