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
629 Develop [js] 양원님이 공유해 주신 유료(5$란다ㅋ) 자료 ㅋㅋ secret hooni 2013.04.23 7948
628 Develop [c++] Win32API를 이용한 ExitWindowsEx 사용한 예제코드 hooni 2013.04.23 7961
627 Develop [c] 퀵정렬(quick sort) 예제 소스.. file hooni 2013.04.23 7974
626 Develop [doc] Equation Solving에 대한 발표자료.. file hooni 2013.04.23 7979
625 Develop [c] 자료구조 그래프(graph) 소스코드 - 확인해볼 것.. file hooni 2013.04.23 7992
624 Develop [c] 문자열 처리 관련 함수들 설명 hooni 2003.04.23 7997
623 Develop [c] 구구단 최단라인 ㅡㅡ; file hooni 2013.04.23 8003
622 Develop 논문에 들어갈 툴바 테스트 해볼 것.. secret hooni 2013.04.23 8013
621 Develop [java] RGB코드를 HEX코드로 변환하는 코드 ㅎㅎ hooni 2013.04.23 8015
620 Develop [c] Unix Domain Socket 을 이용한 IPC hooni 2013.04.23 8017
619 Develop [c] 포인터와 함수포인터에 대해.. hooni 2003.04.23 8019
618 Develop [c] 프로세스 검사하기 hooni 2013.04.23 8027
617 Develop [js] 셀렉트박스(select)의 옵션(option) 동적으로 추가/제거 file hooni 2013.04.23 8060
616 Develop [c] 유닉스 프로그램에서 인수처리 해주는 getopt() 함수 file hooni 2013.04.23 8073
615 Develop [c] 반올림 함수!! ㅋㅋ hooni 2003.04.23 8084
614 Develop [c] 레포트용으로 제출했던 여러 소스코드 모음 file hooni 2003.04.23 8084
Board Pagination Prev 1 ... 33 34 35 36 37 ... 74 Next
/ 74