Contents

조회 수 7488 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
우선 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
번호 분류 제목 글쓴이 날짜 조회 수
417 Etc 여러 대학 및 권위있는 기관 강좌 모음 ㅋㅋ hooni 2013.06.17 15117
416 Etc 영작 연습을 위한 실용영어 문장 1001개 (1~500) hooni 2013.06.21 30419
415 Develop 프로그래밍에서 foo, bar 함수의 유래 file hooni 2013.06.25 21247
414 Etc 성문 종합 영어 정리된 pdf 파일 file hooni 2013.06.25 30942
413 Etc 영어 아주 쉬운 영작문 강의 01~60 secret hooni 2013.06.25 0
412 Etc 영어 관련 토렌트 secret hooni 2013.06.25 0
411 Develop [ios] PHP로 APNS 프로바이더~ file hooni 2013.06.27 16842
410 Develop [ios] APNS 클라이언트 구현 (pdf) file hooni 2013.06.27 15687
409 Develop [ios] APNS 샘플 코드.. secret hooni 2013.06.27 0
408 Develop [android] GCM 사용하기 1 (GCM 서비스 신청하기) file hooni 2013.07.06 51355
407 Develop GCM 사용하기 2 (단말에 GCM 구현하기) file hooni 2013.07.06 23248
406 Develop GCM 사용하기 3 (JSP로 GCM 푸시 서버 만들기) 4 file hooni 2013.07.06 25315
Board Pagination Prev 1 ... 59 60 61 62 63 64 65 66 67 68 ... 98 Next
/ 98