excel匯入匯出

2021-07-22 23:10:11 字數 1566 閱讀 6900

匯出(yii框架中):

header("content-disposition:attachment;filename=123.xls");

$arr=$connection->createcommand("select * from recruit")->queryall();

//$array=$this->db->get("recruit")->result_array();

$str = "編號\t招聘公司\t招聘職位\t工作經驗\t轉正薪資\t招聘人數\t學歷要求\t公司位址\n";

foreach ($arr as $key=>$val)

echo $str;

表裡匯出:

header("content-disposition:attachment;filename=123.xls");

$arr=$connection->createcommand("select * from recruit")->queryall();

//$array=$this->db->get("recruit")->result_array();

$str = "編號\t招聘公司\t招聘職位\t工作經驗\t轉正薪資\t招聘人數\t學歷要求\t公司位址\n";

foreach ($arr as $key=>$val)

echo $str;

匯入:

public function excel_put()    

private function excel_fileput($filepath,$data,$tablename)

}

// 載入excel檔案

$phpexcel = $phpreader->load($filepath);

// 讀取excel檔案中的第乙個工作表

$currentsheet = $phpexcel->getsheet(0);

// 取得最大的列號

$allcolumn = $currentsheet->gethighestcolumn();

// 取得一共有多少行

$allrow = $currentsheet->gethighestrow();

// 從第二行開始輸出,因為excel表中第一行為列名

for($currentrow = 2;$currentrow <= $allrow;$currentrow++)else if($currentcolumn <= $allcolumn)

}

foreach($data as $key=>$val)

$this->db->insert($tablename,$data2);

//print_r($data2);

//echo "

";

}

//echo "\n";

echo "匯入成功";

}

EXCEL匯入匯出

系統管理員登入,系統下資源管理 分機號列表內容匯出 suppresswarnings rawtypes responsebody public jsonobject selectfenjihaoinxitongforexportbyparam requestparam value fenjihao ...

excel匯入匯出

匯出 匯出相對比較簡單在控制層的關鍵 為 string filename 成果資料 dateutils.getdate yyyymmddhhmmss xlsx listpersonneltitlelist personneltitleservice.findlist personneltitle n...

Excel匯入匯出

using system using system.collections.generic using system.data using system.io using system.linq using system.text using system.web using npoi.ss.use...