当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPExcel_NamedRange类代码示例

本文整理汇总了PHP中PHPExcel_NamedRange的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_NamedRange类的具体用法?PHP PHPExcel_NamedRange怎么用?PHP PHPExcel_NamedRange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PHPExcel_NamedRange类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: namedRangeToArray

 /**
  * Create array from a range of cells
  *
  * @param  string $pNamedRange Name of the Named Range
  * @param  mixed  $nullValue Value returned in the array entry if a cell doesn't exist
  * @param  boolean $calculateFormulas  Should formulas be calculated?
  * @param  boolean $formatData  Should formatting be applied to cell values?
  * @param  boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero
  *                                True - Return rows and columns indexed by their actual row and column IDs
  * @return array
  * @throws PHPExcel_Exception
  */
 public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false)
 {
     $namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this);
     if ($namedRange !== NULL) {
         $pWorkSheet = $namedRange->getWorksheet();
         $pCellRange = $namedRange->getRange();
         return $pWorkSheet->rangeToArray($pCellRange, $nullValue, $calculateFormulas, $formatData, $returnCellRef);
     }
     throw new PHPExcel_Exception('Named Range ' . $pNamedRange . ' does not exist.');
 }
开发者ID:andrelotto,项目名称:EmailMarketing,代码行数:22,代码来源:Worksheet.php

示例2: _writeDefinedNameForNamedRange

 /**
  * Write Defined Name for named range
  *
  * @param 	PHPExcel_Shared_XMLWriter	$objWriter 		XML Writer
  * @param 	PHPExcel_NamedRange			$pNamedRange
  * @throws 	PHPExcel_Writer_Exception
  */
 private function _writeDefinedNameForNamedRange(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_NamedRange $pNamedRange)
 {
     // definedName for named range
     $objWriter->startElement('definedName');
     $objWriter->writeAttribute('name', $pNamedRange->getName());
     if ($pNamedRange->getLocalOnly()) {
         $objWriter->writeAttribute('localSheetId', $pNamedRange->getScope()->getParent()->getIndex($pNamedRange->getScope()));
     }
     // Create absolute coordinate and write as raw text
     $range = PHPExcel_Cell::splitRange($pNamedRange->getRange());
     for ($i = 0; $i < count($range); $i++) {
         $range[$i][0] = '\'' . str_replace("'", "''", $pNamedRange->getWorksheet()->getTitle()) . '\'!' . PHPExcel_Cell::absoluteReference($range[$i][0]);
         if (isset($range[$i][1])) {
             $range[$i][1] = PHPExcel_Cell::absoluteReference($range[$i][1]);
         }
     }
     $range = PHPExcel_Cell::buildRange($range);
     $objWriter->writeRawData($range);
     $objWriter->endElement();
 }
开发者ID:Princelo,项目名称:bioerp,代码行数:27,代码来源:Workbook.php

示例3: addNamedRange

 /**
  * Add named range
  *
  * @param  PHPExcel_NamedRange $namedRange
  * @return PHPExcel
  */
 public function addNamedRange(PHPExcel_NamedRange $namedRange)
 {
     if ($namedRange->getScope() == null) {
         // global scope
         $this->namedRanges[$namedRange->getName()] = $namedRange;
     } else {
         // local scope
         $this->namedRanges[$namedRange->getScope()->getTitle() . '!' . $namedRange->getName()] = $namedRange;
     }
     return true;
 }
开发者ID:smallyin,项目名称:ci-phpexcel,代码行数:17,代码来源:phpexcel.php

示例4: extractNamedRange

 /**
  * Extract range values
  *
  * @param	string				&$pRange	String based range representation
  * @param	PHPExcel_Worksheet	$pSheet		Worksheet
  * @return  mixed				Array of values in range if range contains more than one element. Otherwise, a single value is returned.
  * @param	boolean				$resetLog	Flag indicating whether calculation log should be reset or not
  * @throws	PHPExcel_Calculation_Exception
  */
 public function extractNamedRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = NULL, $resetLog = TRUE)
 {
     // Return value
     $returnValue = array();
     //		echo 'extractNamedRange('.$pRange.')<br />';
     if ($pSheet !== NULL) {
         $pSheetName = $pSheet->getTitle();
         //			echo 'Current sheet name is '.$pSheetName.'<br />';
         //			echo 'Range reference is '.$pRange.'<br />';
         if (strpos($pRange, '!') !== false) {
             //				echo '$pRange reference includes sheet reference',PHP_EOL;
             list($pSheetName, $pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
             //				echo 'New sheet name is '.$pSheetName,PHP_EOL;
             //				echo 'Adjusted Range reference is '.$pRange,PHP_EOL;
             $pSheet = $this->_workbook->getSheetByName($pSheetName);
         }
         // Named range?
         $namedRange = PHPExcel_NamedRange::resolveRange($pRange, $pSheet);
         if ($namedRange !== NULL) {
             $pSheet = $namedRange->getWorksheet();
             //				echo 'Named Range '.$pRange.' (';
             $pRange = $namedRange->getRange();
             $splitRange = PHPExcel_Cell::splitRange($pRange);
             //	Convert row and column references
             if (ctype_alpha($splitRange[0][0])) {
                 $pRange = $splitRange[0][0] . '1:' . $splitRange[0][1] . $namedRange->getWorksheet()->getHighestRow();
             } elseif (ctype_digit($splitRange[0][0])) {
                 $pRange = 'A' . $splitRange[0][0] . ':' . $namedRange->getWorksheet()->getHighestColumn() . $splitRange[0][1];
             }
             //				echo $pRange.') is in sheet '.$namedRange->getWorksheet()->getTitle().'<br />';
             //				if ($pSheet->getTitle() != $namedRange->getWorksheet()->getTitle()) {
             //					if (!$namedRange->getLocalOnly()) {
             //						$pSheet = $namedRange->getWorksheet();
             //					} else {
             //						return $returnValue;
             //					}
             //				}
         } else {
             return PHPExcel_Calculation_Functions::REF();
         }
         // Extract range
         $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
         //			var_dump($aReferences);
         if (!isset($aReferences[1])) {
             //	Single cell (or single column or row) in range
             list($currentCol, $currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]);
             $cellValue = NULL;
             if ($pSheet->cellExists($aReferences[0])) {
                 $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
             } else {
                 $returnValue[$currentRow][$currentCol] = NULL;
             }
         } else {
             // Extract cell data for all cells in the range
             foreach ($aReferences as $reference) {
                 // Extract range
                 list($currentCol, $currentRow) = PHPExcel_Cell::coordinateFromString($reference);
                 //					echo 'NAMED RANGE: $currentCol='.$currentCol.' $currentRow='.$currentRow.'<br />';
                 $cellValue = NULL;
                 if ($pSheet->cellExists($reference)) {
                     $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
                 } else {
                     $returnValue[$currentRow][$currentCol] = NULL;
                 }
             }
         }
         //				print_r($returnValue);
         //			echo '<br />';
     }
     // Return
     return $returnValue;
 }
开发者ID:Princelo,项目名称:bioerp,代码行数:81,代码来源:Calculation.php

示例5: getStyle

 /**
  * Get style for cell
  *
  * @param 	string 	$pCellCoordinate	Cell coordinate to get style for
  * @return 	PHPExcel_Style
  * @throws 	Exception
  */
 public function getStyle($pCellCoordinate = 'A1')
 {
     // Worksheet reference?
     if (strpos($pCellCoordinate, '!') !== false) {
         $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCellCoordinate, true);
         return $this->getParent()->getSheetByName($worksheetReference[0])->getStyle($worksheetReference[1]);
     }
     // Named range?
     $namedRange = PHPExcel_NamedRange::resolveRange($pCellCoordinate, $this);
     if (!is_null($namedRange)) {
         $pCoordinate = $namedRange->getRange();
         if ($this->getHashCode() != $namedRange->getWorksheet()->getHashCode()) {
             if (!$namedRange->getLocalOnly()) {
                 return $namedRange->getWorksheet()->getStyle($pCellCoordinate);
             } else {
                 throw new Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle());
             }
         }
     }
     // Uppercase coordinate
     $pCellCoordinate = strtoupper($pCellCoordinate);
     if (eregi(':', $pCellCoordinate)) {
         throw new Exception('Cell coordinate string can not be a range of cells.');
     } else {
         if (eregi('\\$', $pCellCoordinate)) {
             throw new Exception('Cell coordinate string must not be absolute.');
         } else {
             if ($pCellCoordinate == '') {
                 throw new Exception('Cell coordinate can not be zero-length string.');
             } else {
                 // Create a cell for this coordinate.
                 // Reason: When we have an empty cell that has style information,
                 // it should exist for our IWriter
                 $this->getCell($pCellCoordinate);
                 // Check if we already have style information for this cell.
                 // If not, create a new style.
                 if (isset($this->_styles[$pCellCoordinate])) {
                     return $this->_styles[$pCellCoordinate];
                 } else {
                     $newStyle = clone $this->getDefaultStyle();
                     $this->_styles[$pCellCoordinate] = $newStyle;
                     return $newStyle;
                 }
             }
         }
     }
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:54,代码来源:Worksheet.php

示例6: extractNamedRange

 /**
  * Extract range values
  *
  * @param	string				&$pRange	String based range representation
  * @param	PHPExcel_Worksheet	$pSheet		Worksheet
  * @return  mixed				Array of values in range if range contains more than one element. Otherwise, a single value is returned.
  * @throws	Exception
  */
 public function extractNamedRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = null, $resetLog = true)
 {
     // Return value
     $returnValue = array();
     //		echo 'extractNamedRange('.$pRange.')<br />';
     if (!is_null($pSheet)) {
         //			echo 'Current sheet name is '.$pSheet->getTitle().'<br />';
         //			echo 'Range reference is '.$pRange.'<br />';
         if (strpos($pRange, '!') !== false) {
             //				echo '$pRange reference includes sheet reference<br />';
             $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
             $pSheet = $pSheet->getParent()->getSheetByName($worksheetReference[0]);
             //				echo 'New sheet name is '.$pSheet->getTitle().'<br />';
             $pRange = $worksheetReference[1];
             //				echo 'Adjusted Range reference is '.$pRange.'<br />';
         }
         // Named range?
         $namedRange = PHPExcel_NamedRange::resolveRange($pRange, $pSheet);
         if (!is_null($namedRange)) {
             $pSheet = $namedRange->getWorksheet();
             ////			echo 'Named Range '.$pRange.' (';
             $pRange = $namedRange->getRange();
             ////				echo $pRange.') is in sheet '.$namedRange->getWorksheet()->getTitle().'<br />';
             //				if ($pSheet->getTitle() != $namedRange->getWorksheet()->getTitle()) {
             //					if (!$namedRange->getLocalOnly()) {
             //						$pSheet = $namedRange->getWorksheet();
             //					} else {
             //						return $returnValue;
             //					}
             //				}
         } else {
             return PHPExcel_Calculation_Functions::REF();
         }
         // Extract range
         $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
         if (count($aReferences) == 1) {
             list($currentCol, $currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]);
             if ($pSheet->cellExists($aReferences[0])) {
                 $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
             } else {
                 $returnValue[$currentRow][$currentCol] = NULL;
             }
         } else {
             // Extract cell data
             foreach ($aReferences as $reference) {
                 // Extract range
                 list($currentCol, $currentRow) = PHPExcel_Cell::coordinateFromString($reference);
                 //					echo 'NAMED RANGE: $currentCol='.$currentCol.' $currentRow='.$currentRow.'<br />';
                 if ($pSheet->cellExists($reference)) {
                     $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
                 } else {
                     $returnValue[$currentRow][$currentCol] = NULL;
                 }
             }
         }
         //				print_r($returnValue);
         //			echo '<br />';
     }
     // Return
     return $returnValue;
 }
开发者ID:fathitarek,项目名称:cop5725-dbms-project,代码行数:69,代码来源:Calculation.php

示例7: addNamedRange

 /**
  * Add named range
  *
  * @param PHPExcel_NamedRange $namedRange
  * @return PHPExcel
  */
 public function addNamedRange(PHPExcel_NamedRange $namedRange)
 {
     $this->_namedRanges[$namedRange->getWorksheet()->getTitle() . '!' . $namedRange->getName()] = $namedRange;
     return true;
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:11,代码来源:PHPExcel.php

示例8: extractRange

 /**
  * Extract range values
  *
  * @param	string				$pRange		String based range representation
  * @param	PHPExcel_Worksheet	$pSheet		Worksheet
  * @return  mixed				Array of values in range if range contains more than one element. Otherwise, a single value is returned.
  * @throws	Exception
  */
 public function extractRange($pRange = 'A1', PHPExcel_Worksheet $pSheet = null)
 {
     // Return value
     $returnValue = array();
     // Worksheet given?
     if (!is_null($pSheet)) {
         // Worksheet reference?
         if (strpos($pRange, '!') !== false) {
             $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
             $pSheet = $pSheet->getParent()->getSheetByName($worksheetReference[0]);
             $pRange = $worksheetReference[1];
         }
         // Named range?
         $namedRange = PHPExcel_NamedRange::resolveRange($pRange, $pSheet);
         if (!is_null($namedRange)) {
             $pRange = $namedRange->getRange();
             if ($pSheet->getHashCode() != $namedRange->getWorksheet()->getHashCode()) {
                 if (!$namedRange->getLocalOnly()) {
                     $pSheet = $namedRange->getWorksheet();
                 } else {
                     return '';
                 }
             }
         }
         // Extract range
         $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
         if (count($aReferences) == 1) {
             return $pSheet->getCell($aReferences[0])->getCalculatedValue();
         }
         // Extract cell data
         foreach ($aReferences as $reference) {
             // Extract range
             list($currentCol, $currentRow) = PHPExcel_Cell::coordinateFromString($reference);
             $returnValue[$currentCol][$currentRow] = $pSheet->getCell($reference)->getCalculatedValue();
         }
     }
     // Return
     return $returnValue;
 }
开发者ID:electromanlord,项目名称:sgd,代码行数:47,代码来源:Calculation.php

示例9: _writeDefinedNameForNamedRange

 /**
  * Write Defined Name for autoFilter
  *
  * @param 	PHPExcel_Shared_XMLWriter	$objWriter 		XML Writer
  * @param 	PHPExcel_NamedRange			$pNamedRange
  * @throws 	Exception
  */
 private function _writeDefinedNameForNamedRange(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_NamedRange $pNamedRange)
 {
     // definedName for named range
     $objWriter->startElement('definedName');
     $objWriter->writeAttribute('name', $pNamedRange->getName());
     if ($pNamedRange->getLocalOnly()) {
         $objWriter->writeAttribute('localSheetId', $pNamedRange->getWorksheet()->getParent()->getIndex($pNamedRange->getWorksheet()));
     }
     // Create absolute coordinate and write as raw text
     $range = PHPExcel_Cell::splitRange($pNamedRange->getRange());
     $range[0] = PHPExcel_Cell::absoluteCoordinate($range[0]);
     if (isset($range[1])) {
         $range[1] = PHPExcel_Cell::absoluteCoordinate($range[1]);
     }
     $range = implode(':', $range);
     $objWriter->writeRaw('\'' . $pNamedRange->getWorksheet()->getTitle() . '\'!' . $range);
     $objWriter->endElement();
 }
开发者ID:laiello,项目名称:myopensources,代码行数:25,代码来源:Workbook.php

示例10: addNamedRange

	/**
	 * Add named range
	 *
	 * @param PHPExcel_NamedRange $namedRange
	 */
	public function addNamedRange(PHPExcel_NamedRange $namedRange) {
		$this->_namedRanges[$namedRange->getName()] = $namedRange;
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:8,代码来源:PHPExcel.php

示例11: extractNamedRange

 /**
  * Extract range values
  *
  * @param	string				&$pRange	String based range representation
  * @param	PHPExcel_Worksheet	$pSheet		Worksheet
  * @return  mixed				Array of values in range if range contains more than one element. Otherwise, a single value is returned.
  * @param	boolean				$resetLog	Flag indicating whether calculation log should be reset or not
  * @throws	PHPExcel_Calculation_Exception
  */
 public function extractNamedRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = null, $resetLog = true)
 {
     // Return value
     $returnValue = array();
     if ($pSheet !== null) {
         $pSheetName = $pSheet->getTitle();
         if (strpos($pRange, '!') !== false) {
             list($pSheetName, $pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
             $pSheet = $this->_workbook->getSheetByName($pSheetName);
         }
         // Named range?
         $namedRange = PHPExcel_NamedRange::resolveRange($pRange, $pSheet);
         if ($namedRange !== null) {
             $pSheet = $namedRange->getWorksheet();
             $pRange = $namedRange->getRange();
             $splitRange = PHPExcel_Cell::splitRange($pRange);
             //	Convert row and column references
             if (ctype_alpha($splitRange[0][0])) {
                 $pRange = $splitRange[0][0] . '1:' . $splitRange[0][1] . $namedRange->getWorksheet()->getHighestRow();
             } elseif (ctype_digit($splitRange[0][0])) {
                 $pRange = 'A' . $splitRange[0][0] . ':' . $namedRange->getWorksheet()->getHighestColumn() . $splitRange[0][1];
             }
         } else {
             return PHPExcel_Calculation_Functions::REF();
         }
         // Extract range
         $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
         if (!isset($aReferences[1])) {
             //	Single cell (or single column or row) in range
             list($currentCol, $currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]);
             $cellValue = null;
             if ($pSheet->cellExists($aReferences[0])) {
                 $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
             } else {
                 $returnValue[$currentRow][$currentCol] = null;
             }
         } else {
             // Extract cell data for all cells in the range
             foreach ($aReferences as $reference) {
                 // Extract range
                 list($currentCol, $currentRow) = PHPExcel_Cell::coordinateFromString($reference);
                 $cellValue = null;
                 if ($pSheet->cellExists($reference)) {
                     $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
                 } else {
                     $returnValue[$currentRow][$currentCol] = null;
                 }
             }
         }
     }
     // Return
     return $returnValue;
 }
开发者ID:ahmatjan,项目名称:OpenCart-Overclocked,代码行数:62,代码来源:Calculation.php


注:本文中的PHPExcel_NamedRange类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。