PHP 엑셀, CSV 다운로드 함수

All We Need is Data, itself !·2024년 3월 20일
0

Development Journey

목록 보기
6/7
	public function Download() {
		$CODE        = "";
        
		header("Content-type: application/vnd.ms-excel;charset=UTF-8");
		header("Expires: 0");
		header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
		header("Pragma: public");
		header("Content-Disposition: attachment; filename=" . $Params["year"] . "-" . sprintf("%02d", $Params["month"]) . ".csv");
		$CODE .= "Rack,";
		$CODE .= "Power,";
		$CODE .= "\n";
		// 데이터 출력
		if ($Power) {
			foreach ($Power as $PowerN) {
				$CODE .= $PowerN['rack'] . ",";
				$CODE .= $PowerN['power'] . ",";
			}
		} else {
			$CODE .= "내용이 없습니다";
		}
		$CODE = iconv("UTF-8", "euc-kr", $CODE);
		echo $CODE;
	}
profile
분명히 처음엔 데린이었는데,, 이제 개린이인가..

0개의 댓글