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


PHP PHPExcel_Worksheet::getHighestRow方法代码示例

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


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

示例1: insertNewBefore

 /**
  * Insert a new column, updating all possible related data
  *
  * @param	int	$pBefore	Insert before this one
  * @param	int	$pNumCols	Number of columns to insert
  * @param	int	$pNumRows	Number of rows to insert
  * @throws	Exception
  */
 public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = null)
 {
     // Get a copy of the cell collection
     /*$aTemp = $pSheet->getCellCollection();
     		$aCellCollection = array();
     		foreach ($aTemp as $key => $value) {
     			$aCellCollection[$key] = clone $value;
     		}*/
     $aCellCollection = $pSheet->getCellCollection();
     // Get coordinates of $pBefore
     $beforeColumn = 'A';
     $beforeRow = 1;
     list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString($pBefore);
     // Clear cells if we are removing columns or rows
     $highestColumn = $pSheet->getHighestColumn();
     $highestRow = $pSheet->getHighestRow();
     // 1. Clear column strips if we are removing columns
     if ($pNumCols < 0 && PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 + $pNumCols > 0) {
         for ($i = 1; $i <= $highestRow - 1; ++$i) {
             for ($j = PHPExcel_Cell::columnIndexFromString($beforeColumn) - 1 + $pNumCols; $j <= PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2; ++$j) {
                 $coordinate = PHPExcel_Cell::stringFromColumnIndex($j) . $i;
                 $pSheet->removeConditionalStyles($coordinate);
                 if ($pSheet->cellExists($coordinate)) {
                     $pSheet->getCell($coordinate)->setValueExplicit('', PHPExcel_Cell_DataType::TYPE_NULL);
                     $pSheet->getCell($coordinate)->setXfIndex(0);
                 }
             }
         }
     }
     // 2. Clear row strips if we are removing rows
     if ($pNumRows < 0 && $beforeRow - 1 + $pNumRows > 0) {
         for ($i = PHPExcel_Cell::columnIndexFromString($beforeColumn) - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) {
             for ($j = $beforeRow + $pNumRows; $j <= $beforeRow - 1; ++$j) {
                 $coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . $j;
                 $pSheet->removeConditionalStyles($coordinate);
                 if ($pSheet->cellExists($coordinate)) {
                     $pSheet->getCell($coordinate)->setValueExplicit('', PHPExcel_Cell_DataType::TYPE_NULL);
                     $pSheet->getCell($coordinate)->setXfIndex(0);
                 }
             }
         }
     }
     // Loop through cells, bottom-up, and change cell coordinates
     while ($cell = $pNumCols < 0 || $pNumRows < 0 ? array_shift($aCellCollection) : array_pop($aCellCollection)) {
         // New coordinates
         $newCoordinates = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1 + $pNumCols) . ($cell->getRow() + $pNumRows);
         // Should the cell be updated? Move value and cellXf index from one cell to another.
         if (PHPExcel_Cell::columnIndexFromString($cell->getColumn()) >= PHPExcel_Cell::columnIndexFromString($beforeColumn) && $cell->getRow() >= $beforeRow) {
             // Update cell styles
             $pSheet->getCell($newCoordinates)->setXfIndex($cell->getXfIndex());
             $cell->setXfIndex(0);
             // Insert this cell at its new location
             if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
                 // Formula should be adjusted
                 $pSheet->setCellValue($newCoordinates, $this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows));
             } else {
                 // Formula should not be adjusted
                 $pSheet->setCellValue($newCoordinates, $cell->getValue());
             }
             // Clear the original cell
             $pSheet->setCellValue($cell->getCoordinate(), '');
         }
     }
     // Duplicate styles for the newly inserted cells
     $highestColumn = $pSheet->getHighestColumn();
     $highestRow = $pSheet->getHighestRow();
     if ($pNumCols > 0 && PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 > 0) {
         for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) {
             // Style
             $coordinate = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2) . $i;
             if ($pSheet->cellExists($coordinate)) {
                 $xfIndex = $pSheet->getCell($coordinate)->getXfIndex();
                 $conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ? $pSheet->getConditionalStyles($coordinate) : false;
                 for ($j = PHPExcel_Cell::columnIndexFromString($beforeColumn) - 1; $j <= PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 + $pNumCols; ++$j) {
                     $pSheet->getCellByColumnAndRow($j, $i)->setXfIndex($xfIndex);
                     if ($conditionalStyles) {
                         $cloned = array();
                         foreach ($conditionalStyles as $conditionalStyle) {
                             $cloned[] = clone $conditionalStyle;
                         }
                         $pSheet->setConditionalStyles(PHPExcel_Cell::stringFromColumnIndex($j) . $i, $cloned);
                     }
                 }
             }
         }
     }
     if ($pNumRows > 0 && $beforeRow - 1 > 0) {
         for ($i = PHPExcel_Cell::columnIndexFromString($beforeColumn) - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) {
             // Style
             $coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . ($beforeRow - 1);
             if ($pSheet->cellExists($coordinate)) {
                 $xfIndex = $pSheet->getCell($coordinate)->getXfIndex();
//.........这里部分代码省略.........
开发者ID:honj51,项目名称:taobaocrm,代码行数:101,代码来源:ReferenceHelper.php

示例2: __construct

 /**
  * @param \SplFileObject $file            Excel file
  * @param integer        $headerRowNumber Optional number of header row
  * @param integer        $activeSheet     Index of active sheet to read from
  * @param boolean        $readOnly        If set to false, the reader take care of the excel formatting (slow)
  */
 public function __construct(\SplFileObject $file, $headerRowNumber = null, $activeSheet = null, $readOnly = true)
 {
     $reader = \PHPExcel_IOFactory::createReaderForFile($file->getPathName());
     $reader->setReadDataOnly($readOnly);
     /** @var \PHPExcel $excel */
     $excel = $reader->load($file->getPathname());
     if (null !== $activeSheet) {
         $excel->setActiveSheetIndex($activeSheet);
     }
     $this->worksheet = $excel->getActiveSheet();
     $this->maxColumn = $this->worksheet->getHighestColumn();
     $this->maxRow = $this->worksheet->getHighestRow();
     if (null !== $headerRowNumber) {
         $this->setHeaderRowNumber($headerRowNumber);
     }
 }
开发者ID:tegansnyder,项目名称:data-import,代码行数:22,代码来源:ExcelReader.php

示例3: mapHeaders

 /**
  *
  * @throws PhpExcelException
  */
 private function mapHeaders()
 {
     $keys = array_keys($this->loweredFields);
     $columns = array_fill_keys($keys, null);
     $this->loweredFieldNameToExcelColumnMap = [];
     $lastRow = $this->activeSheet->getHighestRow();
     for ($i = $this->headerRow; $i <= $lastRow; $i++) {
         foreach ($this->excelColumnsRange as $columnIndex) {
             $value = $this->activeSheet->getCell($columnIndex . $i)->getCalculatedValue();
             $text = $this->lowerHeaderCellText($value);
             if (array_key_exists($text, $columns)) {
                 $columns[$text] = $columnIndex;
             }
         }
         $this->loweredFieldNameToExcelColumnMap = array_filter($columns);
         if (count($this->loweredFieldNameToExcelColumnMap) > 0) {
             $this->firstDataRow = $i + 1;
             break;
         }
     }
     $missingColumns = array_diff_key($this->loweredToOriginalKeysMap, $this->loweredFieldNameToExcelColumnMap);
     if (count($missingColumns) > 0) {
         throw new PhpExcelException('Missing columns: ' . implode(', ', $missingColumns));
     }
 }
开发者ID:meridius,项目名称:phpexcel,代码行数:29,代码来源:Reader.php

示例4: parse

 /**
  * Разобрать накладную
  *
  * @throws ParseTorg12Exception
  */
 public function parse()
 {
     if (!file_exists($this->filePath)) {
         throw new ParseTorg12Exception('Указан некорректный путь к файлу накладной');
     }
     // читаем файл в формате Excel по форме ТОРГ12
     try {
         $objPHPExcel = \PHPExcel_IOFactory::load($this->filePath);
     } catch (\Exception $e) {
         $errorMsg = 'Невозможно прочитать загруженный файл: ' . $e->getMessage();
         throw new ParseTorg12Exception($errorMsg);
     }
     // создаем накладную
     $this->invoice = new models\Invoice();
     foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
         $this->setWorksheet($worksheet);
         // очищаем список критических ошибок, т.к. накладная может быть не на первом листе
         $this->invoice->errors = [];
         // определяем последнюю строку документа
         $this->highestRow = $this->worksheet->getHighestRow();
         // определяем последний столбец документа
         $this->highestColumn = \PHPExcel_Cell::columnIndexFromString($this->worksheet->getHighestColumn());
         // разбираем заголовок накладной
         $this->parseHeader();
         // разбираем заголовок строк накладной
         $this->parseRowsHeader();
         // разбираем строки накладной, выкидываем дубли заголовка и т.п.
         $this->parseRows();
         // обрабатываем строки накладной
         $this->processRows();
         // если в накладной есть строки, то не обрабатываем остальные листы
         if (count($this->invoice->rows)) {
             // проверяем, что обработаны все строки накладной
             $lastRow = end($this->invoice->rows);
             if ($lastRow->num != count($this->invoice->rows)) {
                 $this->invoice->errors['count_rows'] = 'Порядковый номер последней строки накладной не совпадает с количеством обработанных строк';
             }
             break;
         }
     }
 }
开发者ID:golovchanskiy,项目名称:parse-torg12,代码行数:46,代码来源:ParseTorg12.php

示例5: insertNewBefore

    /**
     * Insert a new column, updating all possible related data
     *
     * @param 	int	$pBefore	Insert before this one
     * @param 	int	$pNumCols	Number of columns to insert
     * @param 	int	$pNumRows	Number of rows to insert
     * @throws 	Exception
     */
    public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = null) {
		// Get a copy of the cell collection
		/*$aTemp = $pSheet->getCellCollection();
		$aCellCollection = array();
		foreach ($aTemp as $key => $value) {
			$aCellCollection[$key] = clone $value;
		}*/
		$aCellCollection = $pSheet->getCellCollection();

    	// Get coordinates of $pBefore
    	$beforeColumn 	= 'A';
    	$beforeRow		= 1;
    	list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore );


		// Remove cell styles?
		$highestColumn 	= $pSheet->getHighestColumn();
		$highestRow 	= $pSheet->getHighestRow();

		if ($pNumCols < 0 && PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 + $pNumCols > 0) {
			for ($i = 1; $i <= $highestRow - 1; $i++) {

				$pSheet->duplicateStyle(
					new PHPExcel_Style(),
					(PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($beforeColumn) - 1 + $pNumCols ) . $i) . ':' . (PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 ) . $i)
				);

			}
		}

		if ($pNumRows < 0 && $beforeRow - 1 + $pNumRows > 0) {
			for ($i = PHPExcel_Cell::columnIndexFromString($beforeColumn) - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; $i++) {

				$pSheet->duplicateStyle(
					new PHPExcel_Style(),
					(PHPExcel_Cell::stringFromColumnIndex($i) . ($beforeRow + $pNumRows)) . ':' . (PHPExcel_Cell::stringFromColumnIndex($i) . ($beforeRow - 1))
				);

			}
		}


   		// Loop trough cells, bottom-up, and change cell coordinates
		while ( ($cell = ($pNumCols < 0 || $pNumRows < 0) ? array_shift($aCellCollection) : array_pop($aCellCollection)) ) {
			// New coordinates
			$newCoordinates = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1 + $pNumCols ) . ($cell->getRow() + $pNumRows);

			// Should the cell be updated?
			if (
					(PHPExcel_Cell::columnIndexFromString( $cell->getColumn() ) >= PHPExcel_Cell::columnIndexFromString($beforeColumn)) &&
				 	($cell->getRow() >= $beforeRow)
				 ) {

				// Update cell styles
				$pSheet->duplicateStyle( $pSheet->getStyle($cell->getCoordinate()), $newCoordinates . ':' . $newCoordinates );
				$pSheet->duplicateStyle( $pSheet->getDefaultStyle(), $cell->getCoordinate() . ':' . $cell->getCoordinate() );

				// Insert this cell at its new location
				if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
					// Formula should be adjusted
					$pSheet->setCellValue(
						  $newCoordinates
						, $this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows)
					);
				} else {
					// Formula should not be adjusted
					$pSheet->setCellValue($newCoordinates, $cell->getValue());
				}

				// Clear the original cell
				$pSheet->setCellValue($cell->getCoordinate(), '');
			}
		}


		// Duplicate styles for the newly inserted cells
		$highestColumn 	= $pSheet->getHighestColumn();
		$highestRow 	= $pSheet->getHighestRow();

		if ($pNumCols > 0 && PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 > 0) {
			for ($i = $beforeRow; $i <= $highestRow - 1; $i++) {

				// Style
				$pSheet->duplicateStyle(
					$pSheet->getStyle(
						(PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 ) . $i)
					),
					($beforeColumn . $i) . ':' . (PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 + $pNumCols ) . $i)
				);

			}
		}
//.........这里部分代码省略.........
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:ReferenceHelper.php

示例6: resetEnd

 /**
  * (Re)Set the end row
  *
  * @param integer	$endRow	The row number at which to stop iterating
  * @return PHPExcel_Worksheet_RowIterator
  */
 public function resetEnd($endRow = null)
 {
     $this->_endRow = $endRow ? $endRow : $this->_subject->getHighestRow();
     return $this;
 }
开发者ID:ahmatjan,项目名称:OpenCart-Overclocked,代码行数:11,代码来源:RowIterator.php

示例7: getDayTest

 function getDayTest(PHPExcel $objPHPExcel, PHPExcel_Worksheet $sheet, $col = 'A', $row = 1, $day = 'ПОНЕДЕЛЬНИК')
 {
     $b = false;
     $index_sheet = $objPHPExcel->getActiveSheetIndex();
     $rowHiestIndex = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn($row));
     for ($i = 0; $i <= $rowHiestIndex; $i++) {
         $cell_value = $this->getValueMergedCell($objPHPExcel, $index_sheet, $this->arr_merged_allCells, $i, $row);
         if ($cell_value == $day) {
             return $b = true;
         }
     }
     if (!$b) {
         $colHiestIndex = $sheet->getHighestRow($col);
         for ($i = 0; $i <= $colHiestIndex; $i++) {
             $cell_value = $this->getValueMergedCell($objPHPExcel, $index_sheet, $this->arr_merged_allCells, $col, $i);
             if ($cell_value == $day) {
                 return $b = true;
             }
         }
     }
     return $b;
 }
开发者ID:ViktorKITP,项目名称:schedule,代码行数:22,代码来源:finder.php

示例8: excel_to_mysql


//.........这里部分代码省略.........
                     $ignore_columns[] = $index;
                     unset($columns[$index]);
                 } else {
                     if ($table_types) {
                         $columns_types[] = "{$value} {$table_types[$index]}";
                     } else {
                         $columns_types[] = "{$value} TEXT NOT NULL";
                     }
                 }
             }
             // Если указаны ключевые поля, то создаем массив ключей
             if ($table_keys) {
                 $columns_keys = array();
                 foreach ($table_keys as $key => $value) {
                     $columns_keys[] = "{$value} (`{$key}`)";
                 }
                 $columns_keys_list = implode(", ", $columns_keys);
                 $columns_keys = ", {$columns_keys_list}";
             } else {
                 $columns_keys = null;
             }
             $columns_types_list = implode(", ", $columns_types);
             $query_string = "CREATE TABLE IF NOT EXISTS {$table_name} ({$columns_types_list}{$columns_keys}) COLLATE = '{$table_encoding}' ENGINE = {$table_engine}";
             if (defined("EXCEL_MYSQL_DEBUG")) {
                 if (EXCEL_MYSQL_DEBUG) {
                     var_dump($query_string);
                 }
             }
             // Создаем таблицу MySQL
             if ($this->mysql_connect->query($query_string)) {
                 // Коллекция значений уникального столбца для удаления несуществующих строк в файле импорта (используется при обновлении)
                 $id_list_in_import = array();
                 // Количество строк на листе Excel
                 $rows_count = $worksheet->getHighestRow();
                 // Получаем массив всех объединенных ячеек
                 $all_merged_cells = $worksheet->getMergeCells();
                 // Перебираем строки листа Excel
                 for ($row = $start_row_index ? $start_row_index : (is_array($columns_names) ? 1 : $columns_names + 1); $row <= $rows_count; $row++) {
                     // Строка со значениями всех столбцов в строке листа Excel
                     $values = array();
                     // Перебираем столбцы листа Excel
                     for ($column = 0; $column < $columns_count; $column++) {
                         if (in_array($column, $ignore_columns)) {
                             continue;
                         }
                         // Строка со значением объединенных ячеек листа Excel
                         $merged_value = null;
                         // Ячейка листа Excel
                         $cell = $worksheet->getCellByColumnAndRow($column, $row);
                         // Перебираем массив объединенных ячеек листа Excel
                         foreach ($all_merged_cells as $merged_cells) {
                             // Если текущая ячейка - объединенная,
                             if ($cell->isInRange($merged_cells)) {
                                 // то вычисляем значение первой объединенной ячейки, и используем её в качестве значения текущей ячейки
                                 $merged_value = explode(":", $merged_cells);
                                 $merged_value = $worksheet->getCell($merged_value[0])->getValue();
                                 break;
                             }
                         }
                         // Проверяем, что ячейка не объединенная: если нет, то берем ее значение, иначе значение первой объединенной ячейки
                         $value = strlen($merged_value) == 0 ? $cell->getValue() : $merged_value;
                         // Если задан массив функций с условиями
                         if ($condition_functions) {
                             if (isset($condition_functions[$columns_names[$column]])) {
                                 // Проверяем условие
                                 if (!$condition_functions[$columns_names[$column]]($value)) {
开发者ID:herasimenia,项目名称:excel_mysql,代码行数:67,代码来源:excel_mysql.php

示例9: loadSheet

 /**
  * 
  * @param PHPExcel_Worksheet $sheet
  */
 private function loadSheet($sheet)
 {
     $name = $sheet->getTitle();
     $entity_name = "Entity_{$name}";
     if (!class_exists($entity_name, true)) {
         print "entity class not found. skip. {$entity_name}";
         return;
     }
     // ヘッダ
     $rowIterator = $sheet->getRowIterator();
     if (!$rowIterator->valid()) {
         print "no data. skip. {$entity_name}";
         return;
     }
     $col = array();
     $row = $rowIterator->current();
     $cellIterator = $row->getCellIterator();
     while ($cellIterator->valid()) {
         $cell = $cellIterator->current();
         $col[] = trim($cell->getValue());
         $cellIterator->next();
     }
     $rowIterator->next();
     print "load {$entity_name} .... ";
     // データを登録
     while ($rowIterator->valid()) {
         $row = $rowIterator->current();
         $entity = $this->c->getEntity($entity_name);
         $cellIterator = $row->getCellIterator();
         $i = 0;
         while ($cellIterator->valid()) {
             $cell = $cellIterator->current();
             $prop = $col[$i];
             $entity->{$prop} = trim($cell->getValue());
             $cellIterator->next();
             $i++;
         }
         $entity->insert();
         $rowIterator->next();
     }
     print $sheet->getHighestRow() - 1 . " rows loaded.\n";
     return;
 }
开发者ID:miztaka,项目名称:teeple2,代码行数:47,代码来源:DataLoader.php

示例10: createProductArray

 /**
  * creates another worksheet
  *
  * @return PHPExcel_Worksheet objWorksheet
  */
 public function createProductArray(&$objPHPExcel)
 {
     $produkteAufgaben = new PHPExcel_Worksheet($objPHPExcel);
     $produkteAufgaben->setTitle('Aufgaben Produkte');
     $firstSheet = $objPHPExcel->getSheet(0);
     $anzahlTeilnehmer = $firstSheet->getCell('C4')->getValue();
     $endzeile = $anzahlTeilnehmer + 6;
     $lastColumnRawData = $firstSheet->getHighestColumn();
     $aufgabenwerte = $firstSheet->rangeToArray('G7:' . $lastColumnRawData . $endzeile, 0, true, false);
     //$produkteAufgaben->fromArray($aufgabenwerte, NULL, 'A1', true);
     $transponierteAufgabenwerte = PHPExcel_Calculation_LookupRef::TRANSPOSE($aufgabenwerte);
     //$produkteAufgaben->fromArray($transponierteAufgabenwerte, NULL, 'A150', true);
     $endmatrix = PHPExcel_Calculation_MathTrig::MMULT($transponierteAufgabenwerte, $aufgabenwerte);
     $produkteAufgaben->fromArray($endmatrix, NULL, 'A1', true);
     $lastColumnMMULTData = $produkteAufgaben->getHighestColumn();
     $lastRowMMULTData = $produkteAufgaben->getHighestRow();
     $maxColumn = $lastColumnMMULTData;
     $maxColumn++;
     $writeRow = $lastRowMMULTData + 2;
     for ($column = 'A'; $column != $maxColumn; $column++) {
         $cell = $produkteAufgaben->getCell($column . $writeRow);
         $cell->setValue('=SUM(' . $column . '1:' . $column . $lastRowMMULTData . ')');
     }
     $objPHPExcel->addSheet($produkteAufgaben);
 }
开发者ID:kyro46,项目名称:TestStatisticsExport,代码行数:30,代码来源:class.ilTestStatisticsExportPlugin.php

示例11: _writeSheetData

 /**
  * Write SheetData
  *
  * @param	PHPExcel_Shared_XMLWriter		$objWriter		XML Writer
  * @param	PHPExcel_Worksheet				$pSheet			Worksheet
  * @param	string[]						$pStringTable	String table
  * @throws	Exception
  */
 private function _writeSheetData(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pStringTable = null)
 {
     if (is_array($pStringTable)) {
         // Flipped stringtable, for faster index searching
         $aFlippedStringTable = $this->getParentWriter()->getWriterPart('stringtable')->flipStringTable($pStringTable);
         // sheetData
         $objWriter->startElement('sheetData');
         // Get column count
         $colCount = PHPExcel_Cell::columnIndexFromString($pSheet->getHighestColumn());
         // Highest row number
         $highestRow = $pSheet->getHighestRow();
         // Loop through cells
         $cellCollection = $pSheet->getCellCollection();
         $cellsByRow = array();
         foreach ($cellCollection as $cell) {
             $cellsByRow[$cell->getRow()][] = $cell;
         }
         for ($currentRow = 1; $currentRow <= $highestRow; ++$currentRow) {
             // Get row dimension
             $rowDimension = $pSheet->getRowDimension($currentRow);
             // Write current row?
             $writeCurrentRow = isset($cellsByRow[$currentRow]) || $rowDimension->getRowHeight() >= 0 || $rowDimension->getVisible() == false || $rowDimension->getCollapsed() == true || $rowDimension->getOutlineLevel() > 0 || $rowDimension->getXfIndex() !== null;
             if ($writeCurrentRow) {
                 // Start a new row
                 $objWriter->startElement('row');
                 $objWriter->writeAttribute('r', $currentRow);
                 $objWriter->writeAttribute('spans', '1:' . $colCount);
                 // Row dimensions
                 if ($rowDimension->getRowHeight() >= 0) {
                     $objWriter->writeAttribute('customHeight', '1');
                     $objWriter->writeAttribute('ht', PHPExcel_Shared_String::FormatNumber($rowDimension->getRowHeight()));
                 }
                 // Row visibility
                 if ($rowDimension->getVisible() == false) {
                     $objWriter->writeAttribute('hidden', 'true');
                 }
                 // Collapsed
                 if ($rowDimension->getCollapsed() == true) {
                     $objWriter->writeAttribute('collapsed', 'true');
                 }
                 // Outline level
                 if ($rowDimension->getOutlineLevel() > 0) {
                     $objWriter->writeAttribute('outlineLevel', $rowDimension->getOutlineLevel());
                 }
                 // Style
                 if ($rowDimension->getXfIndex() !== null) {
                     $objWriter->writeAttribute('s', $rowDimension->getXfIndex());
                     $objWriter->writeAttribute('customFormat', '1');
                 }
                 // Write cells
                 if (isset($cellsByRow[$currentRow])) {
                     foreach ($cellsByRow[$currentRow] as $cell) {
                         // Write cell
                         $this->_writeCell($objWriter, $pSheet, $cell, $pStringTable, $aFlippedStringTable);
                     }
                 }
                 // End row
                 $objWriter->endElement();
             }
         }
         $objWriter->endElement();
     } else {
         throw new Exception("Invalid parameters passed.");
     }
 }
开发者ID:honj51,项目名称:taobaocrm,代码行数:73,代码来源:Worksheet.php

示例12: ParseWorksheet

 /**
  * 
  * @param PHPExcel_Worksheet $worksheet
  * @return void
  */
 private function ParseWorksheet($worksheet)
 {
     // Format is as follows:
     // (gray bg)    [ <description of data> ], <relation1>,    <relationN>
     //              <srcConcept>,              <tgtConcept1>,  <tgtConceptN>
     //              <srcAtomA>,                <tgtAtom1A>,    <tgtAtomNA>
     //              <srcAtomB>,                <tgtAtom1B>,    <tgtAtomNB>
     //              <srcAtomC>,                <tgtAtom1C>,    <tgtAtomNC>
     // Loop through all rows
     $highestrow = $worksheet->getHighestRow();
     $highestcolumn = $worksheet->getHighestColumn();
     $highestcolumnnr = PHPExcel_Cell::columnIndexFromString($highestcolumn);
     $row = 1;
     // Go to the first row where a table starts.
     for ($i = $row; $i <= $highestrow; $i++) {
         $row = $i;
         $cellvalue = $worksheet->getCell('A' . $row)->getValue();
         if (substr(trim($cellvalue), 0, 1) === '[') {
             break;
         }
     }
     // We are now at the beginning of a table or at the end of the file.
     $lines = array();
     // Line is a buffer of one or more related (subsequent) excel rows
     while ($row <= $highestrow) {
         // Read this line as an array of values
         $line = array();
         // values is a buffer containing the cells in a single excel row
         for ($columnnr = 0; $columnnr < $highestcolumnnr; $columnnr++) {
             $columnletter = PHPExcel_Cell::stringFromColumnIndex($columnnr);
             $cell = $worksheet->getCell($columnletter . $row);
             $cellvalue = (string) $cell->getCalculatedValue();
             // overwrite $cellvalue in case of datetime
             // the @ is a php indicator for a unix timestamp (http://php.net/manual/en/datetime.formats.compound.php), later used for typeConversion
             if (PHPExcel_Shared_Date::isDateTime($cell) && !empty($cellvalue)) {
                 $cellvalue = '@' . (string) PHPExcel_Shared_Date::ExcelToPHP($cellvalue);
             }
             $line[] = $cellvalue;
         }
         $lines[] = $line;
         // add line (array of values) to the line buffer
         $row++;
         // Is this relation table done? Then we parse the current values into function calls and reset it
         $firstCellInRow = (string) $worksheet->getCell('A' . $row)->getCalculatedValue();
         if (substr(trim($firstCellInRow), 0, 1) === '[') {
             // Relation table is complete, so it can be processed.
             $this->ParseLines($lines);
             $lines = array();
         }
     }
     // Last relation table remains to be processed.
     $this->ParseLines($lines);
     $lines = array();
 }
开发者ID:AmpersandTarski,项目名称:Ampersand,代码行数:59,代码来源:ExcelImport.php

示例13: count

 public function count()
 {
     return $this->_subject->getHighestRow();
 }
开发者ID:ahmatjan,项目名称:Scene-Editor-for-mobile,代码行数:4,代码来源:RowArrayIterator.php

示例14: lastRow

 function lastRow(PHPExcel_Worksheet $sheet, $indexCellDAY)
 {
     //получаем индекс последней строки в ЛИСТЕ
     $higestRow = $sheet->getHighestRow();
     for ($i = $indexCellDAY; $i <= $higestRow; $i++) {
         $tempRow = $sheet->getCellByColumnAndRow(0, $i)->getFormattedValue();
         if (mb_strtoupper(trim($tempRow)) == "СУББОТА") {
             return ++$i;
         }
     }
 }
开发者ID:ViktorKITP,项目名称:schedule,代码行数:11,代码来源:parserXLS.php

示例15: valid

 /**
  * Indicate if more rows exist in the worksheet
  *
  * @return boolean
  */
 public function valid()
 {
     return $this->_position <= $this->_subject->getHighestRow();
 }
开发者ID:adit-gudhel,项目名称:simpus-dev,代码行数:9,代码来源:RowIterator.php


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