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


PHP PHPExcel_Cell::getColumn方法代码示例

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


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

示例1: _processTokenStack

 private function _processTokenStack($tokens, $cellID = NULL, PHPExcel_Cell $pCell = NULL)
 {
     if ($tokens == FALSE) {
         return FALSE;
     }
     //	If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent cell collection),
     //		so we store the parent cell collection so that we can re-attach it when necessary
     $pCellWorksheet = $pCell !== NULL ? $pCell->getWorksheet() : NULL;
     $pCellParent = $pCell !== NULL ? $pCell->getParent() : null;
     $stack = new PHPExcel_Calculation_Token_Stack();
     //	Loop through each token in turn
     foreach ($tokens as $tokenData) {
         //			print_r($tokenData);
         //			echo '<br />';
         $token = $tokenData['value'];
         //			echo '<b>Token is '.$token.'</b><br />';
         // if the token is a binary operator, pop the top two values off the stack, do the operation, and push the result back on the stack
         if (isset(self::$_binaryOperators[$token])) {
             //				echo 'Token is a binary operator<br />';
             //	We must have two operands, error if we don't
             if (($operand2Data = $stack->pop()) === NULL) {
                 return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
             }
             if (($operand1Data = $stack->pop()) === NULL) {
                 return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
             }
             $operand1 = self::_dataTestReference($operand1Data);
             $operand2 = self::_dataTestReference($operand2Data);
             //	Log what we're doing
             if ($token == ':') {
                 $this->_debugLog->writeDebugLog('Evaluating Range ', $this->_showValue($operand1Data['reference']), ' ', $token, ' ', $this->_showValue($operand2Data['reference']));
             } else {
                 $this->_debugLog->writeDebugLog('Evaluating ', $this->_showValue($operand1), ' ', $token, ' ', $this->_showValue($operand2));
             }
             //	Process the operation in the appropriate manner
             switch ($token) {
                 //	Comparison (Boolean) Operators
                 case '>':
                     //	Greater than
                 //	Greater than
                 case '<':
                     //	Less than
                 //	Less than
                 case '>=':
                     //	Greater than or Equal to
                 //	Greater than or Equal to
                 case '<=':
                     //	Less than or Equal to
                 //	Less than or Equal to
                 case '=':
                     //	Equality
                 //	Equality
                 case '<>':
                     //	Inequality
                     $this->_executeBinaryComparisonOperation($cellID, $operand1, $operand2, $token, $stack);
                     break;
                     //	Binary Operators
                 //	Binary Operators
                 case ':':
                     //	Range
                     $sheet1 = $sheet2 = '';
                     if (strpos($operand1Data['reference'], '!') !== FALSE) {
                         list($sheet1, $operand1Data['reference']) = explode('!', $operand1Data['reference']);
                     } else {
                         $sheet1 = $pCellParent !== NULL ? $pCellWorksheet->getTitle() : '';
                     }
                     if (strpos($operand2Data['reference'], '!') !== FALSE) {
                         list($sheet2, $operand2Data['reference']) = explode('!', $operand2Data['reference']);
                     } else {
                         $sheet2 = $sheet1;
                     }
                     if ($sheet1 == $sheet2) {
                         if ($operand1Data['reference'] === NULL) {
                             if (trim($operand1Data['value']) != '' && is_numeric($operand1Data['value'])) {
                                 $operand1Data['reference'] = $pCell->getColumn() . $operand1Data['value'];
                             } elseif (trim($operand1Data['reference']) == '') {
                                 $operand1Data['reference'] = $pCell->getCoordinate();
                             } else {
                                 $operand1Data['reference'] = $operand1Data['value'] . $pCell->getRow();
                             }
                         }
                         if ($operand2Data['reference'] === NULL) {
                             if (trim($operand2Data['value']) != '' && is_numeric($operand2Data['value'])) {
                                 $operand2Data['reference'] = $pCell->getColumn() . $operand2Data['value'];
                             } elseif (trim($operand2Data['reference']) == '') {
                                 $operand2Data['reference'] = $pCell->getCoordinate();
                             } else {
                                 $operand2Data['reference'] = $operand2Data['value'] . $pCell->getRow();
                             }
                         }
                         $oData = array_merge(explode(':', $operand1Data['reference']), explode(':', $operand2Data['reference']));
                         $oCol = $oRow = array();
                         foreach ($oData as $oDatum) {
                             $oCR = PHPExcel_Cell::coordinateFromString($oDatum);
                             $oCol[] = PHPExcel_Cell::columnIndexFromString($oCR[0]) - 1;
                             $oRow[] = $oCR[1];
                         }
                         $cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)) . min($oRow) . ':' . PHPExcel_Cell::stringFromColumnIndex(max($oCol)) . max($oRow);
                         if ($pCellParent !== NULL) {
                             $cellValue = $this->extractCellRange($cellRef, $this->_workbook->getSheetByName($sheet1), FALSE);
//.........这里部分代码省略.........
开发者ID:Princelo,项目名称:bioerp,代码行数:101,代码来源:Calculation.php

示例2: getDay

 /**
  * @param PHPExcel $objPHPExcel
  * @param PHPExcel_Worksheet $sheet
  * @param string $col
  * @param int|string $row
  * @param string $day
  * @return bool
  * @throws PHPExcel_Exception
  */
 function getDay(PHPExcel $objPHPExcel, PHPExcel_Worksheet $sheet, PHPExcel_Cell $cell, $arr_filter)
 {
     $g = true;
     $b = false;
     $objPHPExcel->setActiveSheetIndexByName($sheet->getTitle());
     $act_sheet = $objPHPExcel->getActiveSheet();
     $index_sheet = $objPHPExcel->getActiveSheetIndex();
     $row = $cell->getRow();
     $column = $cell->getColumn();
     // $cell_v=$cell->getFormattedValue();
     $columnHiestIndex = PHPExcel_Cell::columnIndexFromString($act_sheet->getHighestColumn($row));
     $rowHiestIndex = $act_sheet->getHighestRow();
     $column = PHPExcel_Cell::columnIndexFromString($column);
     //$this->testEcho($rowHiestIndex);
     $cell_value = '';
     for ($i = 0; $i < $column; $i++) {
         $cell_value = $this->getValueMergedCell($objPHPExcel, $index_sheet, $this->arr_merged_allCells, $i, $row);
         //  $this->testEcho($cell_value);
         if (in_array($cell_value, $arr_filter)) {
             //
             //  $this->testEcho($cell_value);
             $b = true;
         }
         if ($b) {
             $g = false;
             break;
         }
     }
     if ($g) {
         for ($i = $column + 1; $i <= $columnHiestIndex; $i++) {
             $cell_value = $this->getValueMergedCell($objPHPExcel, $index_sheet, $this->arr_merged_allCells, $i, $row);
             //  $this->testEcho($cell_value);
             if (in_array($cell_value, $arr_filter)) {
                 //      $this->testEcho($cell_value);
                 $b = true;
             }
             if ($b) {
                 $g = false;
                 break;
             }
         }
     }
     if ($g) {
         for ($i = 0; $i < $row; $i++) {
             $cell_value = $this->getValueMergedCell($objPHPExcel, $index_sheet, $this->arr_merged_allCells, $column, $i);
             //  $this->testEcho($cell_value);
             if (in_array($cell_value, $arr_filter)) {
                 //     $this->testEcho($cell_value);
                 $b = true;
             }
             if ($b) {
                 $g = false;
                 break;
             }
         }
     }
     if ($g) {
         for ($i = $row + 1; $i <= $rowHiestIndex; $i++) {
             $cell_value = $this->getValueMergedCell($objPHPExcel, $index_sheet, $this->arr_merged_allCells, $column, $i);
             //  $this->testEcho($cell_value);
             if (in_array($cell_value, $arr_filter)) {
                 //         $this->testEcho($cell_value);
                 $b = true;
             }
             if ($b) {
                 break;
             }
         }
     }
     /*
             for ($i = 0; $i <= $rowHiestIndex; $i++) {
                 $cell_value = $this->getValueMergedCell($objPHPExcel, $index_sheet, $this->arr_merged_allCells, $i, $row);
               //  $this->testEcho($cell_value);
                 if ($cell_value == $day) {
                   $this->testEcho($cell_value);
                     return $b = true;
                 }
             }
             $this->testEcho('Тестим B');
             $this->testEcho($b);
             if (!$b) {
                 $colHiestIndex = $sheet->getHighestRow($col);
                 $this->testEcho($colHiestIndex);
                 for ($i = 0; $i <= $colHiestIndex; $i++) {
                     $cell_value = $this->getValueMergedCell($objPHPExcel, $index_sheet, $this->arr_merged_allCells, $col, $i);
                     if ($cell_value == $day) {
                         $this->testEcho($cell_value);
                   }
                 }
           }
     */
//.........这里部分代码省略.........
开发者ID:ViktorKITP,项目名称:schedule,代码行数:101,代码来源:finder.php

示例3: compareCells

 /**
  * Compare 2 cells
  *
  * @param    PHPExcel_Cell $a Cell a
  * @param    PHPExcel_Cell $b Cell b
  *
  * @return    int        Result of comparison (always -1 or 1, never zero!)
  */
 public static function compareCells(PHPExcel_Cell $a, PHPExcel_Cell $b)
 {
     if ($a->getRow() < $b->getRow()) {
         return -1;
     } elseif ($a->getRow() > $b->getRow()) {
         return 1;
     } elseif (self::columnIndexFromString($a->getColumn()) < self::columnIndexFromString($b->getColumn())) {
         return -1;
     } else {
         return 1;
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:20,代码来源:Cell.php

示例4: _generateRow


//.........这里部分代码省略.........
                         $cellData = PHPExcel_Style_NumberFormat::toFormattedString($cell->getCalculatedValue(), $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode());
                     } else {
                         $cellData = PHPExcel_Style_NumberFormat::ToFormattedString($cell->getValue(), $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode());
                     }
                     // Convert UTF8 data to PCDATA
                     $cellData = htmlspecialchars($cellData);
                 }
                 // replace leading spaces on each line with &nbsp;
                 $cellData = $this->_convertNbsp($cellData);
                 // convert newline "\n" to '<br>'
                 $cellData = str_replace("\n", '<br/>', $cellData);
                 // Check value
                 if ($cellData == '') {
                     $cellData = '&nbsp;';
                 }
                 // Extend CSS class?
                 if (!$this->_useInlineCss) {
                     $cssClass .= ' style' . $cell->getXfIndex();
                     $cssClass .= ' ' . $cell->getDataType();
                 } else {
                     if (isset($this->_cssStyles['td.style' . $cell->getXfIndex()])) {
                         $cssClass = array_merge($cssClass, $this->_cssStyles['td.style' . $cell->getXfIndex()]);
                     }
                     // General horizontal alignment: Actual horizontal alignment depends on dataType
                     $sharedStyle = $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex());
                     if ($sharedStyle->getAlignment()->getHorizontal() == PHPExcel_Style_Alignment::HORIZONTAL_GENERAL && isset($this->_cssStyles['.' . $cell->getDataType()]['text-align'])) {
                         $cssClass['text-align'] = $this->_cssStyles['.' . $cell->getDataType()]['text-align'];
                     }
                 }
             } else {
                 $cell = new PHPExcel_Cell(PHPExcel_Cell::stringFromColumnIndex($colNum), $pRow + 1, '', PHPExcel_Cell_DataType::TYPE_NULL, $pSheet);
             }
             // Hyperlink?
             if ($cell->hasHyperlink() && !$cell->getHyperlink()->isInternal()) {
                 $cellData = '<a href="' . htmlspecialchars($cell->getHyperlink()->getUrl()) . '" title="' . htmlspecialchars($cell->getHyperlink()->getTooltip()) . '">' . $cellData . '</a>';
             }
             // Column/rowspan
             foreach ($pSheet->getMergeCells() as $cells) {
                 if ($cell->isInRange($cells)) {
                     list($first, ) = PHPExcel_Cell::splitRange($cells);
                     if ($first[0] == $cell->getCoordinate()) {
                         list($colSpan, $rowSpan) = PHPExcel_Cell::rangeDimension($cells);
                     } else {
                         $writeCell = false;
                     }
                     break;
                 }
             }
             // Write
             if ($writeCell) {
                 // Column start
                 $html .= '          <td';
                 if (!$this->_useInlineCss) {
                     $html .= ' class="' . $cssClass . '"';
                 } else {
                     //** Necessary redundant code for the sake of PHPExcel_Writer_PDF **
                     // We must explicitly write the width of the <td> element because TCPDF
                     // does not recognize e.g. <col style="width:42pt">
                     $width = 0;
                     $columnIndex = PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1;
                     for ($i = $columnIndex; $i < $columnIndex + $colSpan; ++$i) {
                         if (isset($this->_columnWidths[$sheetIndex][$i])) {
                             $width += $this->_columnWidths[$sheetIndex][$i];
                         }
                     }
                     $cssClass['width'] = $width . 'pt';
                     // We must also explicitly write the height of the <td> element because TCPDF
                     // does not recognize e.g. <tr style="height:50pt">
                     if (isset($this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]['height'])) {
                         $height = $this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]['height'];
                         $cssClass['height'] = $height;
                     }
                     //** end of redundant code **
                     $html .= ' style="' . $this->_assembleCSS($cssClass) . '"';
                 }
                 if ($colSpan > 1) {
                     $html .= ' colspan="' . $colSpan . '"';
                 }
                 if ($rowSpan > 1) {
                     $html .= ' rowspan="' . $rowSpan . '"';
                 }
                 $html .= '>';
                 // Image?
                 $html .= $this->_writeImageTagInCell($pSheet, $cell->getCoordinate());
                 // Cell data
                 $html .= $cellData;
                 // Column end
                 $html .= '</td>' . "\r\n";
             }
             // Next column
             ++$colNum;
         }
         // Write row end
         $html .= '        </tr>' . "\r\n";
         // Return
         return $html;
     } else {
         throw new Exception("Invalid parameters passed.");
     }
 }
开发者ID:linhanwei,项目名称:TP,代码行数:101,代码来源:HTML.php


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