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


PHP PHPExcel_Worksheet::rangeToArray方法代码示例

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


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

示例1: getRow

 /**
  * Returns row array with offsets as keys.
  * @return array integer => mixed
  */
 protected function getRow()
 {
     // Try to return cached value
     if ($this->position == $this->lastRowPosition) {
         return $this->lastRow;
     }
     $range = sprintf('A%d:%s%1$d', $this->position, \PHPExcel_Cell::stringFromColumnIndex($this->colsCount - 1));
     $rows = $this->sheet->rangeToArray($range);
     $row = array_pop($rows);
     // Cache value
     $this->lastRowPosition = $this->position;
     $this->lastRow = $row;
     return $row;
 }
开发者ID:urmaul,项目名称:importreader,代码行数:18,代码来源:Reader.php

示例2: populateNamedRanges

 private function populateNamedRanges(\PHPExcel_Worksheet $templateSheet)
 {
     $template = $templateSheet->getParent();
     $excelNamedRanges = array_change_key_case($template->getNamedRanges(), CASE_UPPER);
     if (!isset($excelNamedRanges['ROOT'])) {
         throw new \InvalidArgumentException("Missing Named-Range: 'ROOT'");
     }
     $namedRanges = [];
     /** @var \PHPExcel_NamedRange $excelNamedRange */
     foreach ($excelNamedRanges as $name => $excelNamedRange) {
         $namedRanges[$name] = [];
         foreach ($templateSheet->rangeToArray($excelNamedRange->getRange(), null, false, true, true) as $rowNum => $row) {
             $namedRanges[$name][$rowNum - 1] = [];
             foreach ($row as $col => $cellValue) {
                 $colNum = \PHPExcel_Cell::columnIndexFromString($col);
                 $templateCor = $col . $rowNum;
                 $style = $this->getStyleOfCell($templateSheet, $templateCor);
                 $namedRanges[$name][$rowNum - 1][$colNum - 1] = ['value' => $cellValue, 'style' => $style];
             }
         }
     }
     $this->logger->debug('Populated named ranges', array_keys($namedRanges));
     return $namedRanges;
 }
开发者ID:mathielen,项目名称:report-write-engine,代码行数:24,代码来源:ExcelNamedRangeTemplatePopulator.php

示例3: setHeaderRowNumber

 /**
  * Set header row number
  *
  * @param integer $rowNumber Number of the row that contains column header names
  */
 public function setHeaderRowNumber($rowNumber)
 {
     $rowNumber++;
     $this->headerRowNumber = $rowNumber;
     $res = $this->worksheet->rangeToArray(sprintf('A%d:%s%d', $rowNumber, $this->maxColumn, $rowNumber));
     $this->setColumnHeaders(current($res));
     $this->pointer = $rowNumber;
 }
开发者ID:tegansnyder,项目名称:data-import,代码行数:13,代码来源:ExcelReader.php

示例4: _calculateTopTenValue

 private function _calculateTopTenValue($columnID, $startRow, $endRow, $ruleType, $ruleValue)
 {
     $range = $columnID . $startRow . ':' . $columnID . $endRow;
     $dataValues = PHPExcel_Calculation_Functions::flattenArray($this->_workSheet->rangeToArray($range, NULL, TRUE, FALSE));
     $dataValues = array_filter($dataValues);
     if ($ruleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) {
         rsort($dataValues);
     } else {
         sort($dataValues);
     }
     return array_pop(array_slice($dataValues, 0, $ruleValue));
 }
开发者ID:jonpetersen,项目名称:PHTC,代码行数:12,代码来源:AutoFilter.php

示例5: prepararArchivo

/**
 * 
 * @param PHPExcel_Worksheet $hoja
 * @param int $pk representa el índice de la columna en el archivo de excel que está asociada con la llave primaria de la tabla
 * @return string rerpesenta el nombre la ruta del archivo creado. Si no se pudo crear el archivo se regresa otra cosa :p
 */
function prepararArchivo($hoja, $pk = false, $incluirPrimeraFila = false)
{
    $objetoExcel = new PHPExcel();
    $hojaInsertar = $objetoExcel->getSheet(0);
    $hojaInsertar->setTitle('Insertar');
    if ($objetoExcel->getSheetCount() > 1) {
        $hojaActualizar = $objetoExcel->getSheet(1);
        $hojaActualizar->setTitle('Actualizar');
    } else {
        $hojaActualizar = new PHPExcel_Worksheet();
        $hojaActualizar->setTitle('Actualizar');
        $objetoExcel->addSheet($hojaActualizar);
    }
    $rango = $hoja->calculateWorksheetDataDimension();
    if (!$incluirPrimeraFila) {
        $rango[1] = '2';
    }
    $contenidoExcel = $hoja->rangeToArray($rango);
    $datos = array();
    $datos['insertar'] = array();
    $datos['actualizar'] = array();
    if ($pk) {
        $db = new DbConnection();
        $db->abrirConexion();
        $llavePrimaria = $_SESSION['pk'];
        foreach ($contenidoExcel as $fila) {
            $existe = $db->existeRegistro($_SESSION['tabla'], $llavePrimaria, $fila[$pk]);
            if ($existe) {
                $datos['actualizar'][] = $fila;
            } else {
                $datos['insertar'][] = $fila;
            }
        }
        $db->cerrarConexion();
    } else {
        foreach ($contenidoExcel as $fila) {
            $datos['insertar'][] = $fila;
        }
    }
    $hojaInsertar->fromArray($datos['insertar'], null, 'A1', true);
    $hojaActualizar->fromArray($datos['actualizar'], null, 'A1', true);
    $escritorExcel = PHPExcel_IOFactory::createWriter($objetoExcel, 'Excel2007');
    $escritorExcel->save('excelTmp/tmp_import_upload.xlsx');
    return 'excelTmp/tmp_import_upload.xlsx';
}
开发者ID:roy1336,项目名称:ImportadorPHP,代码行数:51,代码来源:lectorExcel.php


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