반응형
250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Node
- <script setup>
- 연산자
- jsp
- 뷰
- 슬라이드기능구현
- vue3 데이터보내기
- 구글폰트다운받아사용
- select
- vue이미지자르기
- 이메일유효성검사
- vue 사진미리보기
- 컴포넌트간 데이터보내기
- 상위컴포넌트에서 하위컴포넌트로 데이터 전달
- vueperslides
- Java
- 클래스지우기
- class지우기
- vue3 props
- 자바변수선언
- vue3
- VUE
- 슬라이드한번에세개
- 엑셀
- nodejs
- vue3emit
- javascript
- vue슬라이드
- vueper slides
- 미리보기
Archives
- Today
- Total
orange056
[PHP] 엑셀다운로드 기능 만들기 본문
728x90
반응형
<div >
<button id="exel_down">엑셀 다운로드</button>
</div>
<script>
$('#exel_down').click(function(){
location.href = "url";
})
</script>
<?php
$file = $_GET['file'];
$mysqli = new mysqli('127.0.0.1', 'root', '비번', '테이블명');
header( "Content-type: application/vnd.ms-excel; charset=utf-8");
header( "Content-Disposition: attachment; filename = excel_test.xls" ); //filename = 저장되는 파일명을 설정합니다.
header( "Content-Description: PHP4 Generated Data" );
//엑셀 파일로 만들고자 하는 데이터의 테이블을 만듭니다.
$EXCEL_FILE = "
<table border='1'>
<tr>
<td>이름</td>
<td>성별</td>
<td>나이</td>
<td>전화번호</td>
<td>사진여부</td>
</tr>
";
$qry = "SELECT * FROM '테이블명'";
$res = $mysqli->query($qry);
// DB 에 저장된 데이터를 테이블 형태로 저장합니다.
while ($row = $res->fetch_object()) {
$EXCEL_FILE .= "
<tr>
<td>".$row->name."</td>
<td>".$row->gender."</td>
<td>".$row->age."</td>
<td>".$row->phone."</td>
<td>".$row->file."</td>
</tr>
";
}
$EXCEL_FILE .= "</table>";
// 만든 테이블을 출력해줘야 만들어진 엑셀파일에 데이터가 나타납니다.
echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>";
echo $EXCEL_FILE;
?>
728x90
반응형
Comments