本文介绍了使用col&的PHP Excel样式格式行索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以在一系列像这样的单元格上应用样式
we can apply a style on a range of cells like this
$objPHPExcel->getActiveSheet()->duplicateStyleArray($array_of_style,"A1:D1");
但是我想对它们的列和行引用中的一系列单元格应用相同的样式
But I want to apply same style to a range of cells on their column and row reference like
(3,4,7,7);
请帮助我.我不是phpexcel的新手,但找不到在col& amp;中给定范围内应用样式的任何方法.行索引.
Please help me on this. I am not a newbie on phpexcel but could not find any method to apply a style on range given in col & row index.
推荐答案
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);
}
这篇关于使用col&的PHP Excel样式格式行索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!