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


PHP Cell::extractAllCellReferencesInRange方法代码示例

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


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

示例1: extractNamedRange

 /**
  * Extract range values
  *
  * @param    string       &$pRange    String based range representation
  * @param    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   Calculation\Exception
  */
 public function extractNamedRange(&$pRange = 'A1', 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) = Worksheet::extractSheetTitle($pRange, true);
             //                echo 'New sheet name is '.$pSheetName, PHP_EOL;
             //                echo 'Adjusted Range reference is '.$pRange, PHP_EOL;
             $pSheet = $this->spreadsheet->getSheetByName($pSheetName);
         }
         // Named range?
         $namedRange = NamedRange::resolveRange($pRange, $pSheet);
         if ($namedRange !== null) {
             $pSheet = $namedRange->getWorksheet();
             //                echo 'Named Range '.$pRange.' (';
             $pRange = $namedRange->getRange();
             $splitRange = 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 Calculation\Functions::REF();
         }
         // Extract range
         $aReferences = Cell::extractAllCellReferencesInRange($pRange);
         //            var_dump($aReferences);
         if (!isset($aReferences[1])) {
             //    Single cell (or single column or row) in range
             list($currentCol, $currentRow) = 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) = 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 $returnValue;
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:80,代码来源:Calculation.php

示例2: load


//.........这里部分代码省略.........
                                 }
                             }
                         }
                         $conditionals = array();
                         if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) {
                             foreach ($xmlSheet->conditionalFormatting as $conditional) {
                                 foreach ($conditional->cfRule as $cfRule) {
                                     if (((string) $cfRule["type"] == Style_Conditional::CONDITION_NONE || (string) $cfRule["type"] == Style_Conditional::CONDITION_CELLIS || (string) $cfRule["type"] == Style_Conditional::CONDITION_CONTAINSTEXT || (string) $cfRule["type"] == Style_Conditional::CONDITION_EXPRESSION) && isset($dxfs[intval($cfRule["dxfId"])])) {
                                         $conditionals[(string) $conditional["sqref"]][intval($cfRule["priority"])] = $cfRule;
                                     }
                                 }
                             }
                             foreach ($conditionals as $ref => $cfRules) {
                                 ksort($cfRules);
                                 $conditionalStyles = array();
                                 foreach ($cfRules as $cfRule) {
                                     $objConditional = new Style_Conditional();
                                     $objConditional->setConditionType((string) $cfRule["type"]);
                                     $objConditional->setOperatorType((string) $cfRule["operator"]);
                                     if ((string) $cfRule["text"] != '') {
                                         $objConditional->setText((string) $cfRule["text"]);
                                     }
                                     if (count($cfRule->formula) > 1) {
                                         foreach ($cfRule->formula as $formula) {
                                             $objConditional->addCondition((string) $formula);
                                         }
                                     } else {
                                         $objConditional->addCondition((string) $cfRule->formula);
                                     }
                                     $objConditional->setStyle(clone $dxfs[intval($cfRule["dxfId"])]);
                                     $conditionalStyles[] = $objConditional;
                                 }
                                 // Extract all cell references in $ref
                                 $aReferences = Cell::extractAllCellReferencesInRange($ref);
                                 foreach ($aReferences as $reference) {
                                     $docSheet->getStyle($reference)->setConditionalStyles($conditionalStyles);
                                 }
                             }
                         }
                         $aKeys = array("sheet", "objects", "scenarios", "formatCells", "formatColumns", "formatRows", "insertColumns", "insertRows", "insertHyperlinks", "deleteColumns", "deleteRows", "selectLockedCells", "sort", "autoFilter", "pivotTables", "selectUnlockedCells");
                         if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) {
                             foreach ($aKeys as $key) {
                                 $method = "set" . ucfirst($key);
                                 $docSheet->getProtection()->{$method}($xmlSheet->sheetProtection[$key] == "true");
                             }
                         }
                         if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) {
                             $docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection["password"], true);
                             if ($xmlSheet->protectedRanges->protectedRange) {
                                 foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) {
                                     $docSheet->protectCells((string) $protectedRange["sqref"], (string) $protectedRange["password"], true);
                                 }
                             }
                         }
                         if ($xmlSheet && $xmlSheet->autoFilter && !$this->_readDataOnly) {
                             $docSheet->setAutoFilter((string) $xmlSheet->autoFilter["ref"]);
                         }
                         if ($xmlSheet && $xmlSheet->mergeCells && $xmlSheet->mergeCells->mergeCell && !$this->_readDataOnly) {
                             foreach ($xmlSheet->mergeCells->mergeCell as $mergeCell) {
                                 $docSheet->mergeCells((string) $mergeCell["ref"]);
                             }
                         }
                         if ($xmlSheet && $xmlSheet->pageMargins && !$this->_readDataOnly) {
                             $docPageMargins = $docSheet->getPageMargins();
                             $docPageMargins->setLeft(floatval($xmlSheet->pageMargins["left"]));
                             $docPageMargins->setRight(floatval($xmlSheet->pageMargins["right"]));
开发者ID:kamaludinnur,项目名称:toko-baju,代码行数:67,代码来源:Excel2007.php

示例3: extractNamedRange

 /**
  * Extract range values
  *
  * @param	string				&$pRange	String based range representation
  * @param	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', 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 = 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 = 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 Calculation_Functions::REF();
         }
         // Extract range
         $aReferences = Cell::extractAllCellReferencesInRange($pRange);
         if (count($aReferences) == 1) {
             list($currentCol, $currentRow) = 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) = 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:bestgoodz,项目名称:toko-baju,代码行数:69,代码来源:Calculation.php

示例4: _readDataValidation


//.........这里部分代码省略.........
         case 0x0:
             $operator = Cell_DataValidation::OPERATOR_BETWEEN;
             break;
         case 0x1:
             $operator = Cell_DataValidation::OPERATOR_NOTBETWEEN;
             break;
         case 0x2:
             $operator = Cell_DataValidation::OPERATOR_EQUAL;
             break;
         case 0x3:
             $operator = Cell_DataValidation::OPERATOR_NOTEQUAL;
             break;
         case 0x4:
             $operator = Cell_DataValidation::OPERATOR_GREATERTHAN;
             break;
         case 0x5:
             $operator = Cell_DataValidation::OPERATOR_LESSTHAN;
             break;
         case 0x6:
             $operator = Cell_DataValidation::OPERATOR_GREATERTHANOREQUAL;
             break;
         case 0x7:
             $operator = Cell_DataValidation::OPERATOR_LESSTHANOREQUAL;
             break;
     }
     // offset: 4; size: var; title of the prompt box
     $offset = 4;
     $string = $this->_readUnicodeStringLong(substr($recordData, $offset));
     $promptTitle = $string['value'] !== chr(0) ? $string['value'] : '';
     $offset += $string['size'];
     // offset: var; size: var; title of the error box
     $string = $this->_readUnicodeStringLong(substr($recordData, $offset));
     $errorTitle = $string['value'] !== chr(0) ? $string['value'] : '';
     $offset += $string['size'];
     // offset: var; size: var; text of the prompt box
     $string = $this->_readUnicodeStringLong(substr($recordData, $offset));
     $prompt = $string['value'] !== chr(0) ? $string['value'] : '';
     $offset += $string['size'];
     // offset: var; size: var; text of the error box
     $string = $this->_readUnicodeStringLong(substr($recordData, $offset));
     $error = $string['value'] !== chr(0) ? $string['value'] : '';
     $offset += $string['size'];
     // offset: var; size: 2; size of the formula data for the first condition
     $sz1 = $this->_GetInt2d($recordData, $offset);
     $offset += 2;
     // offset: var; size: 2; not used
     $offset += 2;
     // offset: var; size: $sz1; formula data for first condition (without size field)
     $formula1 = substr($recordData, $offset, $sz1);
     $formula1 = pack('v', $sz1) . $formula1;
     // prepend the length
     try {
         $formula1 = $this->_getFormulaFromStructure($formula1);
         // in list type validity, null characters are used as item separators
         if ($type == Cell_DataValidation::TYPE_LIST) {
             $formula1 = str_replace(chr(0), ',', $formula1);
         }
     } catch (Exception $e) {
         return;
     }
     $offset += $sz1;
     // offset: var; size: 2; size of the formula data for the first condition
     $sz2 = $this->_GetInt2d($recordData, $offset);
     $offset += 2;
     // offset: var; size: 2; not used
     $offset += 2;
     // offset: var; size: $sz2; formula data for second condition (without size field)
     $formula2 = substr($recordData, $offset, $sz2);
     $formula2 = pack('v', $sz2) . $formula2;
     // prepend the length
     try {
         $formula2 = $this->_getFormulaFromStructure($formula2);
     } catch (Exception $e) {
         return;
     }
     $offset += $sz2;
     // offset: var; size: var; cell range address list with
     $cellRangeAddressList = $this->_readBIFF8CellRangeAddressList(substr($recordData, $offset));
     $cellRangeAddresses = $cellRangeAddressList['cellRangeAddresses'];
     foreach ($cellRangeAddresses as $cellRange) {
         $stRange = $this->_phpSheet->shrinkRangeToFit($cellRange);
         $stRange = Cell::extractAllCellReferencesInRange($stRange);
         foreach ($stRange as $coordinate) {
             $objValidation = $this->_phpSheet->getCell($coordinate)->getDataValidation();
             $objValidation->setType($type);
             $objValidation->setErrorStyle($errorStyle);
             $objValidation->setAllowBlank((bool) $allowBlank);
             $objValidation->setShowInputMessage((bool) $showInputMessage);
             $objValidation->setShowErrorMessage((bool) $showErrorMessage);
             $objValidation->setShowDropDown(!$suppressDropDown);
             $objValidation->setOperator($operator);
             $objValidation->setErrorTitle($errorTitle);
             $objValidation->setError($error);
             $objValidation->setPromptTitle($promptTitle);
             $objValidation->setPrompt($prompt);
             $objValidation->setFormula1($formula1);
             $objValidation->setFormula2($formula2);
         }
     }
 }
开发者ID:bestgoodz,项目名称:toko-baju,代码行数:101,代码来源:Excel5.php

示例5: mergeCells

 /**
  * Set merge on a cell range
  *
  * @param 	string			$pRange		Cell range (e.g. A1:E1)
  * @throws	Exception
  * @return Worksheet
  */
 public function mergeCells($pRange = 'A1:A1')
 {
     // Uppercase coordinate
     $pRange = strtoupper($pRange);
     if (strpos($pRange, ':') !== false) {
         $this->_mergeCells[$pRange] = $pRange;
         // make sure cells are created
         // get the cells in the range
         $aReferences = Cell::extractAllCellReferencesInRange($pRange);
         // create upper left cell if it does not already exist
         $upperLeft = $aReferences[0];
         if (!$this->cellExists($upperLeft)) {
             $this->getCell($upperLeft)->setValueExplicit(null, Cell_DataType::TYPE_NULL);
         }
         // create or blank out the rest of the cells in the range
         $count = count($aReferences);
         for ($i = 1; $i < $count; $i++) {
             $this->getCell($aReferences[$i])->setValueExplicit(null, Cell_DataType::TYPE_NULL);
         }
     } else {
         throw new Exception('Merge must be set on a range of cells.');
     }
     return $this;
 }
开发者ID:bestgoodz,项目名称:toko-baju,代码行数:31,代码来源:Worksheet.php

示例6: setConditionalStyles

 /**
  * Set Conditional Styles. Only used on supervisor.
  *
  * @param Style_Conditional[]	$pValue	Array of condtional styles
  * @return Style
  */
 public function setConditionalStyles($pValue = null)
 {
     if (is_array($pValue)) {
         foreach (Cell::extractAllCellReferencesInRange($this->getSelectedCells()) as $cellReference) {
             $this->getActiveSheet()->setConditionalStyles($cellReference, $pValue);
         }
     }
     return $this;
 }
开发者ID:bestgoodz,项目名称:toko-baju,代码行数:15,代码来源:Style.php


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