Thinkphp5 do excel table import and export

public function excel(){
        if (request()->isPost()) {

            Loader::import('PHPExcel.PHPExcel');
            Loader::import('PHPExcel.PHPExcel.PHPExcel_IOFactory');
            Loader::import('PHPExcel.PHPExcel.PHPExcel_Cell');
            // instantiate PHPExcel
            $objPHPExcel = new PHPExcel();
            $file = request()->file('excel');
            if ($file) {
                $file_types = explode(".", $_FILES ['excel'] ['name']); // ["name"] => string(25) "excel filename.xls"
                $file_type = $file_types [count($file_types) - 1];//xls suffix Dump ($file_type);
                die;
                $file_name = $file_types [count($file_types) - 2];//xls to suffix file name 
                /* to determine whether it is an .xls file, to determine whether it is an excel file */
                if (strtolower($file_type) != "xls" && strtolower($file_type) != "xlsx") {
                    echo ' is not an Excel file, re-upload '; die;
                }
                $info = $file->rule('uniqid')->move(ROOT_PATH . 'public' . DS . 'excel');//Upload location
                $path = ROOT_PATH . 'public' . DS . 'excel' . DS;
                $file_path = $path . $info->getSaveName();//Uploaded EXCEL path 
               //Get the data of the uploaded excel form, form an array 
                $re = $this->actionRead($file_path, 'utf-8');
                array_splice($re, 1, 0);
                unset($re[0]);
                /* Change the key of the array to a custom name */
                $keys = array('id', 'username', 'nickname', 'password', 'salt', 'avatar', 'email', 'loginfailure', 'logintime', 'createtime', 'updatetime','token','status');
                foreach ($re as $i => $vals) {
                    $re[$i] = array_combine($keys, $vals);
                }
                 // traverse array write database 
                for ($i = 1; $i < count($re); $i++) {
                    $data = $re[$i];
                    $res = db('admin')->insert($data);
                }
            }
        }
    }
 public function actionRead($filename, $encode = 'utf-8')
    {
        $objReader = PHPExcel_IOFactory::createReader('Excel2007');
        $objReader->setReadDataOnly(true);
        $objPHPExcel = $objReader->load($filename);
        $objWorksheet = $objPHPExcel->getActiveSheet();
        $highestRow = $objWorksheet->getHighestRow();
         $highestColumn = $objWorksheet->getHighestColumn();
         $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
         $excelData = array();
         for($row = 1; $row <= $highestRow; $row++)
         {
         for ($col = 0; $col < $highestColumnIndex; $col++)
         {
         $excelData[$row][]=(string)$objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
         }
         }
         return $excelData;
    }
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form  action="{:url('admin/index/excel')}" enctype="multipart/form-data" method="post">
    <input type="file" name="excel" /> <br>
    <input type="submit" value="Upload"/>
</form>
</body>
</html>