Contents

조회 수 7491 댓글 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를 활용해서 필드명을 계속 가져오게 하면 쉽게 처리 됩니다.


?

  1. [c#] 파일(File) 쓰기 ㅎㅎ

    Date2013.04.23 CategoryDevelop Byhooni Views13300
    Read More
  2. [php] 한샘 전자발주 시스템..

    Date2013.04.23 CategoryDevelop Byhooni Views11989
    Read More
  3. [jsp] RSS(xml) 파싱해서 보여주기 ㅎㅎ

    Date2013.04.23 CategoryDevelop Byhooni Views13217
    Read More
  4. [windows] 최근 열어본 문서목록 안나오게 하는 방법

    Date2013.04.23 CategorySystem/OS Byhooni Views25487
    Read More
  5. [php] 심플한 게시판 ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views12995
    Read More
  6. [ppt] 뚜레쥬르 온라인 마케팅 제안서

    Date2013.04.23 CategoryPPT Byhooni Views23501
    Read More
  7. [c++] 현승이가 준 P2P 프로그램 소스 ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views12074
    Read More
  8. [c++] BHO 프로그램 동작 원리.. 간단하게..

    Date2013.04.23 CategoryDevelop Byhooni Views43108
    Read More
  9. [ppt] 시스템보안 연구실 ppt 템플릿.. (CIST)

    Date2013.04.23 CategoryPPT Byhooni Views20873
    Read More
  10. 스파이웨어(BHO) 탐지하는 방법..

    Date2013.04.23 CategoryEtc Byhooni Views44415
    Read More
  11. OPT와 CAS에 대한 자료.. (교수님 메일로 보내드린 자료..)

    Date2013.04.23 CategoryDevelop Byhooni Views13928
    Read More
  12. [doc] 테크니컬 레포트 (BHO 취약점을 이용한 공격)

    Date2013.04.23 CategoryDevelop Byhooni Views27086
    Read More
Board Pagination Prev 1 ... 43 44 45 46 47 48 49 50 51 52 ... 98 Next
/ 98