Ejemplo n.º 1
0
 /**
  * Detect payments column.
  *
  * @return variable with column index.
  */
 private function detectPayments()
 {
     foreach ($this->sheet->getActiveSheet()->getRowIterator() as $row) {
         foreach ($row->getCellIterator() as $cell) {
             if (strcasecmp($cell->getValue(), 'pagamento') === 0 || strcasecmp($cell->getValue(), 'pago') === 0 || strcasecmp($cell->getValue(), 'valor') === 0) {
                 $this->paymentColumn = PHPExcel_Cell::columnIndexFromString($cell->getColumn());
                 $this->firstRow = $cell->getRow() + 1;
                 return;
             }
         }
     }
     $columns = array_fill(1, PHPExcel_Cell::columnIndexFromString($this->sheet->getActiveSheet()->getHighestColumn()), 0);
     foreach ($this->sheet->getActiveSheet()->getRowIterator() as $row) {
         foreach ($row->getCellIterator() as $cell) {
             if (preg_match("/[0-9]/", $cell->getValue())) {
                 $string = Helper::mb_str_split($cell->getValue());
                 foreach ($string as $char) {
                     if (ctype_digit($char)) {
                         $columns[PHPExcel_Cell::columnIndexFromString($cell->getColumn())]++;
                     }
                 }
             }
         }
     }
     $this->paymentColumn = array_keys($columns, max($columns))[0];
 }