我们可以在这样的单元格上应用样式
$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);
}