我们可以在这样的单元格上应用样式
$objPHPExcel->getActiveSheet()->duplicateStyleArray($array_of_style,"A1:D1");
但我想将相同的样式应用于其列和行引用上的一系列单元格
(3,4,7,7);
请帮帮我.我不是phpexcel的新手,但找不到任何方法来应用col& amp;行索引.
解决方法:
function duplicateStyleArrayByColumnAndRow( PHPExcel $objPHPExcel,
$styleArray = array(),
$fromRow = 1,
$fromCol = 0,
$toRow = 1,
$toCol = 0
)
{
if ($fromRow > $toRow) {
$r = $fromRow; $fromRow = $toRow; $toRow = $r;
}
if ($fromCol > $toCol) {
$c = $fromCol; $fromCol = $toCol; $toCol = $c;
}
$fromCell = PHPExcel_Cell::stringFromColumnIndex($fromCol) . $fromRow;
$toCell = PHPExcel_Cell::stringFromColumnIndex($toCol) . $toRow;
$cellRange = $fromCell . ':' . $toCell;
if ($fromCell === $toCell) {
$cellRange = $fromCell;
}
return $objPHPExcel->getActiveSheet()->duplicateStyleArray($styleArray,$cellRange);
}