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

?

  1. [node.js] 지금 하고 있는거..

    Date2013.04.23 CategoryDevelop Byhooni Views26978
    Read More
  2. [node.js] nodejs 기본 설치

    Date2013.04.23 CategoryDevelop Byhooni Views26254
    Read More
  3. [mysql] 양력, 음력 DB데이터

    Date2013.04.23 CategoryDevelop Byhooni Views7802
    Read More
  4. [maven] Mac OS에 메이븐(maven) 설치하기

    Date2015.01.21 CategoryDevelop Byhooni Views1110
    Read More
  5. [matlab] 정보은닉 스테가노그래피(Steganography) 수업

    Date2016.10.03 CategoryDevelop Byhooni Views684
    Read More
  6. [matlab] ZigZag-Scanning (2-D Array)

    Date2016.10.15 CategoryDevelop Byhooni Views1992
    Read More
  7. [linux] 프로세스 관련 시스템콜

    Date2003.04.23 CategoryDevelop Byhooni Views7827
    Read More
  8. [linux] 임베디드 리눅스 (embedded linux)

    Date2013.04.23 CategoryDevelop Byhooni Views7354
    Read More
  9. [linux] 쉘 스크립트를 이용한 BBS

    Date2003.04.23 CategoryDevelop Byhooni Views10047
    Read More
  10. [linux] 날짜나 파일의 내용으로 검색하는 방법(find 명령 사용)

    Date2013.04.23 CategoryDevelop Byhooni Views8118
    Read More
  11. [linux] tar 명령어 뽀개기.. ㅋㅋ

    Date2003.04.23 CategoryDevelop Byhooni Views7669
    Read More
  12. [linux] crond 사용법.. ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views7246
    Read More
  13. [linux] CentOS Apache 웹서버에 HTTPS 적용

    Date2015.10.23 CategoryDevelop Byhooni Views788
    Read More
  14. [lego] 세그웨이 이것만 볼것.. ㅎㅎ

    Date2013.04.23 CategoryDevelop Byhooni Views33536
    Read More
  15. [kotlin] 코틀린 안드로이드 앱 버전/빌드 정보

    Date2020.12.15 CategoryDevelop Byhooni Views822
    Read More
  16. [js]모바일 웹에서 orientationchange

    Date2013.04.23 CategoryDevelop Byhooni Views19359
    Read More
Board Pagination Prev 1 ... 7 8 9 10 11 ... 53 Next
/ 53