채택완료

엑셀파일로 다운로드받는방법

2017-09-04 (월) 12:09:43 4,084

그누보드를 사용하는 유저입니다.

게시판리스트에서 해당 글 뷰페이지로 이동하게되면 그내용에 대해서 엑셀로 다운을받고싶은데..어떻해하면좋을까요..?

|

답변 3개

채택된 답변
+20 포인트

<?

ob_start();

include_once($_SERVER['DOCUMENT_ROOT'] ."/common.php");

header("Content-type:application/vnd.ms-excel");

header("Content-Disposition:attachment;filename=view.xls");

$is_title="엑셀 문서 다운로드";

$bo_table=$_GET['bo_table'];

$wr_id=(int)$_GET['wr_id'];

$sql="select * from g5_write_".$bo_table." where wr_is_comment=0 and wr_id='{$wr_id}'";

$is_print=sql_fetch($sql);

?>

<!doctype html>

<html lang="ko">

<head>

<meta charset="UTF-8">

<style type="text/css">

.txt {mso-number-format:'\@'}

</style>

<title><?=$is_title?></title>

</head>

<body>

<table>

<tr>

<th scope="col">번호</th>

<th scope="col">글쓴이</th>

<th scope="col">제목</th>

<th scope="col">글내용</th>

<th scope="col">조회수</th>

<th scope="col">날짜</th>

</tr>

<tr>

<td class='txt'><?=$is_print['wr_id']?></td>

<td class='txt'><?=$is_print['wr_name']?></td>

<td class='txt'><?=$is_print['wr_subject']?></td>

<td class='txt'><?=$is_print['wr_content']?></td>

<td class='txt'><?=$is_print['wr_hit']?></td>

<td class='txt'><?=$is_print['wr_datetime']?></td>

</tr>

</table>

</body>

</html>

위에 소스를 excel_view.php 이름으로 저장후 사용중인 게시판 스킨 폴더안으로 업로드를 합니다. 

게시판 스킨 폴더 > view_skin.php 파일 소스 적당한 자리를 선택후 아래의 링크를 추가해 보세요.

<a href="<?=$board_skin_url?>/excel_view.php?bo_table=<?=$bo_table?>&wr_id=<?=$view['wr_id']?>">엑셀보기</a>

아래의 링크를 참고하세요.

https://sir.kr/g5_skin/11199 

답변을 작성하려면 로그인이 필요합니다.