public function toArray($sheet_name,$ext=false)
  {
    if(!$ext){
      $ext=pathinfo($sheet_name, PATHINFO_EXTENSION);
    }
    switch ($ext) {
      case 'csv':
      $reader = ReaderFactory::create(Type::CSV);
      break;
      case 'ods':
      $reader = ReaderFactory::create(Type::ODS);
      break;
      case 'xlsx':
      $reader = ReaderFactory::create(Type::XLSX);
      break;
    }
    $reader->open($sheet_name);
    foreach ($reader->getSheetIterator() as $sheet) {
      $sheetName = $sheet->getName();
      foreach ($sheet->getRowIterator() as $row) {
        $list['lists'][$sheetName][]=$row;
      }
    }
    $reader->close();
    $lists=false;
    foreach ($list['lists'] as $key => $value) {
      $lists[$key]=$this->sheetToAlpha($value);
    }
    if($ext=="csv"){
      return $lists[""];
    }else{
      return $lists;
    }
  }
public function toArray($sheet_name,$ext=false)
  {
    if(!$ext){
      $ext=pathinfo($sheet_name, PATHINFO_EXTENSION);
    }
    switch ($ext) {
      case 'csv':
      $reader = ReaderFactory::create(Type::CSV);
      break;
      case 'ods':
      $reader = ReaderFactory::create(Type::ODS);
      break;
      case 'xlsx':
      $reader = ReaderFactory::create(Type::XLSX);
      break;
    }
    $reader->open($sheet_name);
    foreach ($reader->getSheetIterator() as $sheet) {
      $sheetName = $sheet->getName();
      foreach ($sheet->getRowIterator() as $row) {
        $list['lists'][$sheetName][]=$row;
      }
    }
    $reader->close();
    $lists=false;
    foreach ($list['lists'] as $key => $value) {
      $lists[$key]=$this->sheetToAlpha($value);
    }
    if($ext=="csv"){
      return $lists[""];
    }else{
      return $lists;
    }
  }
public function toArray ( $ sheet_name , $ ext = false ) { if ( ! $ ext ) { $ ext = pathinfo ( $ sheet_name , PATHINFO_EXTENSION ) ; } switch ( $ ext ) { case 'csv' : $ reader = ReaderFactory :: create ( Type :: CSV ) ; break ; case 'ods' : $ reader = ReaderFactory :: create ( Type :: ODS ) ; break ; case 'xlsx' : $ reader = ReaderFactory :: create ( Type :: XLSX ) ; break ; } $ reader -> open ( $ sheet_name ) ; foreach ( $ reader -> getSheetIterator ( ) as $ sheet ) { $ sheetName = $ sheet -> getName ( ) ; foreach ( $ sheet -> getRowIterator ( ) as $ row ) { $ list [ 'lists' ] [ $ sheetName ] [ ] = $ row ; } } $ reader -> close ( ) ; $ lists = false ; foreach ( $ list [ 'lists' ] as $ key => $ value ) { $ lists [ $ key ] = $ this -> sheetToAlpha ( $ value ) ; } if ( $ ext == "csv" ) { return $ lists [ "" ] ; } else { return $ lists ; } }
Converte uma planilha para array
Converte uma planilha para array