Hello,
a quick (dirty) fix to greatly speedup styles assignment. What do you think about it?
The method getCellXfByHashCode() is awfully slow, so I tried to replace it with a cache array.
version: 1.8.0
file: PHPExcel/Style.php
method: applyFromArray()
new code:
a quick (dirty) fix to greatly speedup styles assignment. What do you think about it?
The method getCellXfByHashCode() is awfully slow, so I tried to replace it with a cache array.
version: 1.8.0
file: PHPExcel/Style.php
method: applyFromArray()
new code:
global $__cache;
if (!isset($__cache)) {
$__cache = array();
}
$hashCode = $newStyle->getHashCode();
if (isset($__cache[$hashCode])) {
$newXfIndexes[$oldXfIndex] = $__cache[$hashCode];
} else {
// we don't have such a cell Xf, need to add
$workbook->addCellXf($newStyle);
$newXfIndexes[$oldXfIndex] = $newStyle->getIndex();
$__cache[$hashCode] = $newStyle->getIndex();
}
old code:if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) {
$newXfIndexes[$oldXfIndex] = $existingStyle->getIndex();
} else {
// we don't have such a cell Xf, need to add
$workbook->addCellXf($newStyle);
$newXfIndexes[$oldXfIndex] = $newStyle->getIndex();
}