Jeden workround dla może być użycie indeksów styl xf:
$xfIndex = $activeSheet->getCell('A1')->getXfIndex();
Następnie ustawić tę wartość dla xfIndex wszystkich komórek w zakresie
for ($col = 'D'; $col != 'E'; ++$col) {
for ($row = 1; $row <= 100; ++$row) {
$activeSheet->getCell($col . $row)->setXfIndex($xfIndex);
}
}
EDIT
Alternatywnie, zastosuj poprawkę do metody duplicateStyle() w Classes/PHPExcel/Worksheet.php
linie 1479 do 1486 obecnie następujący:
if ($this->_parent->cellXfExists($pCellStyle)) {
// there is already this cell Xf in our collection
$xfIndex = $pCellStyle->getIndex();
} else {
// we don't have such a cell Xf, need to add
$workbook->addCellXf($pCellStyle);
$xfIndex = $pCellStyle->getIndex();
}
zmiana:
if ($existingStyle = $this->_parent->getCellXfByHashCode($pCellStyle->getHashCode())) {
// there is already such cell Xf in our collection
$xfIndex = $existingStyle->getIndex();
} else {
// we don't have such a cell Xf, need to add
$workbook->addCellXf($pCellStyle);
$xfIndex = $pCellStyle->getIndex();
}
Podobnie w sposobie applyFromArray() w klasach/PHPExcel/Style.php
linie 425 do 432 obecnie:
if ($workbook->cellXfExists($newStyle)) {
// there is already such cell Xf in our collection
$newXfIndexes[$oldXfIndex] = $existingStyle->getIndex();
} else {
// we don't have such a cell Xf, need to add
$workbook->addCellXf($newStyle);
$newXfIndexes[$oldXfIndex] = $newStyle->getIndex();
}
zmiana na:
if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) {
// there is already such cell Xf in our collection
$newXfIndexes[$oldXfIndex] = $existingStyle->getIndex();
} else {
// we don't have such a cell Xf, need to add
$workbook->addCellXf($newStyle);
$newXfIndexes[$oldXfIndex] = $newStyle->getIndex();
}
EDIT # 2
Fix został wciśnięty do gałęzi rozwoju na github. Daje niewielki efekt wydajnościowy, w zależności od liczby używanych stylów ... Postaram się uzyskać szybszą wersję jutro wieczorem
Dzięki Mark - plastry działały idealnie. Szalona obsługa fantastycznego produktu. –
Znalazłem niezwykle przydatne metody getXfIndex() i setXfIndex(). Szkoda, że dokument PHPExcel jest tak skąpy, ponieważ bez tej odpowiedzi nigdy bym nie zgadł, czym jest Xf. – soger
@soger - Równie dobrze się bawimy, zastanawiając się, co 'xf' pochodzi z dokumentacji Microsoftu, a także –