public function toSheet($array, $sheet_name, $ext=false)
  {
    if(!$ext){
      $ext=pathinfo($sheet_name, PATHINFO_EXTENSION);  
    }
    switch ($ext) {
      case 'csv':
      $writer = WriterFactory::create(Type::CSV);
      break;
      case 'ods':
      $writer = WriterFactory::create(Type::ODS);
      break;
      case 'xlsx':
      $writer = WriterFactory::create(Type::XLSX);
      break;
    }
    @$writer->openToFile($sheet_name);
    foreach ($array as $row) {
      $writer->addRow($row);
    }
    if (is_null($writer->close())) {
      return true;
    } else {
      return false;
    }
  }
public function toSheet($array, $sheet_name, $ext=false)
  {
    if(!$ext){
      $ext=pathinfo($sheet_name, PATHINFO_EXTENSION);  
    }
    switch ($ext) {
      case 'csv':
      $writer = WriterFactory::create(Type::CSV);
      break;
      case 'ods':
      $writer = WriterFactory::create(Type::ODS);
      break;
      case 'xlsx':
      $writer = WriterFactory::create(Type::XLSX);
      break;
    }
    @$writer->openToFile($sheet_name);
    foreach ($array as $row) {
      $writer->addRow($row);
    }
    if (is_null($writer->close())) {
      return true;
    } else {
      return false;
    }
  }
public function toSheet ( $ array , $ sheet_name , $ ext = false ) { if ( ! $ ext ) { $ ext = pathinfo ( $ sheet_name , PATHINFO_EXTENSION ) ; } switch ( $ ext ) { case 'csv' : $ writer = WriterFactory :: create ( Type :: CSV ) ; break ; case 'ods' : $ writer = WriterFactory :: create ( Type :: ODS ) ; break ; case 'xlsx' : $ writer = WriterFactory :: create ( Type :: XLSX ) ; break ; } @ $ writer -> openToFile ( $ sheet_name ) ; foreach ( $ array as $ row ) { $ writer -> addRow ( $ row ) ; } if ( is_null ( $ writer -> close ( ) ) ) { return true ; } else { return false ; } }
Converte um array de dados para uma planilha
Converte um array de dados para uma planilha