Views 7488 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
우선 excel이나 ms-word로 변환할려면 아래의 헤더부분이 필요합니다. 
<? 
    // 엑셀의 경우
    header( "Content-type: application/vnd.ms-excel" ); 
    header( "Content-Disposition: attachment; filename=파일명.xls" ); 
    header( "Content-Description: PHP4 Generated Data" ); 
    
    // 워드일 경우
    header( "Content-type: application/vnd.ms-word" ); 
    header( "Content-Disposition: attachment; filename=파일명.doc" ); 
    header( "Content-Description: PHP4 Generated Data" ); 
?>

그 다음엔 엑셀에서 자기가 원하는 표를 구성합니다. 
그리고 구성한 엑셀파일을 웹페이지로 저장합니다. (엑셀에서 웹페이지로 저장이 가능합니다.) <- 이 부분이 핵심이라고 할 수 있겠네요. 
그런다음 메모장이나 기타 에디터로 여시고 상단에 위의 헤더를 추가합니다. 
그리고 해당 셀부분에 DB에서 해당하는 필드값을 넣어줍니다. 
워드도 같은 방식으로 구성하면 됩니다. 


엑셀 변환시 샘플코드
<?
    include "./DBConn.php";
    
    header( "Content-type: application/vnd.ms-excel" ); 
    header( "Content-Disposition: attachment; filename=업체관리.xls" ); 
    header( "Content-Description: PHP4 Generated Data" ); 
    
    $table_data = mysql_query("SELECT * FROM company order by BC_REGDATE desc");
?>
<?
    while( $data = mysql_fetch_array( $table_data ) ) :
    
    $bc_no=$data[BC_NO];
    $bc_company=stripslashes($data[BC_COMPANY]);
    $bc_name=stripslashes($data[BC_NAME]);
    $bc_comno=$data[BC_COMNO];
    $bc_address1=stripslashes($data[BC_ADDRESS1]);
    $bc_address2=stripslashes($data[BC_ADDRESS2]);
?>
<html>
<table>
<tr>
<td> <?echo "$bc_company"; ?> </td>
</tr>
<?$i++; endwhile;?>
</table>
</html>


또 다른 샘플.. ㅋㅋ

<html>
...

<table>
<?php
    $table_data = mysql_query("SELECT * FROM company order by BC_REGDATE desc");
    while( $data = mysql_fetch_array( $table_data ) ) :
    {
        echo "<tr>";
        
        foreach($data as $field)
        {
            echo "<td>";
            echo $field;
            echo "</td>";
        }
        echo "</tr>";
    }
?>
</table>

</html>

foreach를 활용해서 필드명을 계속 가져오게 하면 쉽게 처리 됩니다.

?

List of Articles
No. Category Subject Author Date Views
1173 [ios] 인앱결제 & 오토레이아웃 관련 강좌 secret hooni 2013.11.14 0
1172 PPT 네오웹 세미나 자료~ secret hooni 2013.05.28 0
1171 Develop [iphone] PerfectlyClear 보정솔루션 최신.. secret hooni 2013.05.28 0
1170 PPT [doc] BHO관련 발표 자료(디펜스에 쓸꺼) secret hooni 2013.05.28 0
1169 Develop [ios] IB 없이 개발하기 (html) secret hooni 2013.05.31 0
1168 Develop [ios] 스터디 자료 (from 종길M) secret hooni 2013.06.04 0
1167 Develop [ios] 패스(path) 앱 메뉴 스타일 secret hooni 2013.06.11 0
1166 Etc 영어 아주 쉬운 영작문 강의 01~60 secret hooni 2013.06.25 0
1165 Etc 영어 관련 토렌트 secret hooni 2013.06.25 0
1164 Develop 이어서 작업할 내용~ secret hooni 2013.11.21 0
1163 Develop [ios] APNS 샘플 코드.. secret hooni 2013.06.27 0
1162 Develop [ios] 최신 UI 모음.. (나중에 정리할 것) secret hooni 2013.08.09 0
1161 Develop 아이 훌레시 작업중 ㅋㅋ secret hooni 2013.08.09 0
1160 Etc IoT가 만드는 미래와 플랫폼 경쟁력 secret hooni 2014.09.23 0
1159 Develop [js] 2048 예쁘게 만들고 있는거.. ㅋㄷ secret hooni 2015.01.30 0
1158 Etc IPR 특허 관련 secret hooni 2015.04.28 0
Board Pagination Prev 1 2 3 4 5 ... 74 Next
/ 74