本文整理汇总了PHP中PHPExcel_Cell::setXfIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Cell::setXfIndex方法的具体用法?PHP PHPExcel_Cell::setXfIndex怎么用?PHP PHPExcel_Cell::setXfIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Cell
的用法示例。
在下文中一共展示了PHPExcel_Cell::setXfIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCell
/**
* Get cell at a specific coordinate
*
* @param string $pCoordinate Coordinate of the cell
* @throws Exception
* @return PHPExcel_Cell Cell that was found
*/
public function getCell($pCoordinate = 'A1')
{
// Check cell collection
if ($this->_cellCollection->isDataSet($pCoordinate)) {
return $this->_cellCollection->getCacheData($pCoordinate);
}
// Worksheet reference?
if (strpos($pCoordinate, '!') !== false) {
$worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
return $this->getParent()->getSheetByName($worksheetReference[0])->getCell($worksheetReference[1]);
}
// Named range?
if (!preg_match('/^' . PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $pCoordinate, $matches) && preg_match('/^' . PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $pCoordinate, $matches)) {
$namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
if (!is_null($namedRange)) {
$pCoordinate = $namedRange->getRange();
return $namedRange->getWorksheet()->getCell($pCoordinate);
}
}
// Uppercase coordinate
$pCoordinate = strtoupper($pCoordinate);
if (strpos($pCoordinate, ':') !== false || strpos($pCoordinate, ',') !== false) {
throw new Exception('Cell coordinate can not be a range of cells.');
} elseif (strpos($pCoordinate, '$') !== false) {
throw new Exception('Cell coordinate must not be absolute.');
} else {
// Create new cell object
// Coordinates
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
// $cell = $this->_cellCollection->addCacheData($pCoordinate,new PHPExcel_Cell($aCoordinates[0], $aCoordinates[1], null, PHPExcel_Cell_DataType::TYPE_NULL, $this));
$cell = new PHPExcel_Cell($aCoordinates[0], $aCoordinates[1], null, PHPExcel_Cell_DataType::TYPE_NULL, $this);
$this->_cellCollectionIsSorted = false;
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0])) {
$this->_cachedHighestColumn = $aCoordinates[0];
}
if ($this->_cachedHighestRow < $aCoordinates[1]) {
$this->_cachedHighestRow = $aCoordinates[1];
}
// Cell needs appropriate xfIndex
$rowDimensions = $this->getRowDimensions();
$columnDimensions = $this->getColumnDimensions();
if (isset($rowDimensions[$aCoordinates[1]]) && $rowDimensions[$aCoordinates[1]]->getXfIndex() !== null) {
// then there is a row dimension with explicit style, assign it to the cell
$cell->setXfIndex($rowDimensions[$aCoordinates[1]]->getXfIndex());
} else {
if (isset($columnDimensions[$aCoordinates[0]])) {
// then there is a column dimension, assign it to the cell
$cell->setXfIndex($columnDimensions[$aCoordinates[0]]->getXfIndex());
} else {
// set to default index
$cell->setXfIndex(0);
}
}
return $cell;
}
}