code: public function actionExportExcel()
      {
          $searchModel = new MahasiswaSearch();
          $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
          
          $objReader = \PHPExcel_IOFactory::createReader('Excel2007');
          $template = Yii::getAlias('@hscstudio/export').'/templates/phpexcel/export.xlsx';
          $objPHPExcel = $objReader->load($template);
          $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(\PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
          $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(\PHPExcel_Worksheet_PageSetup::PAPERSIZE_FOLIO);
          $baseRow=2; // line 2
          foreach($dataProvider->getModels() as $mahasiswa){
              $objPHPExcel->getActiveSheet()->setCellValue('A'.$baseRow, $baseRow-1);
              $objPHPExcel->getActiveSheet()->setCellValue('B'.$baseRow, $mahasiswa->nama);
              $objPHPExcel->getActiveSheet()->setCellValue('C'.$baseRow, $mahasiswa->nim);
              $baseRow++;
          }
          header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
          header('Content-Disposition: attachment;filename="export.xlsx"');
          header('Cache-Control: max-age=0');
          $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel2007");
          $objWriter->save('php://output');
          exit;
      }
docs: /*
  EXPORT WITH PHPEXCEL