웹솔루션개발 25년 노하우! 해피CGI의 모든것

[해피CGI][cgimall] table2excel - jQuery 로 HTML을 EXCEL 로 변환하기 본문

웹프로그램밍 자료실/JAVA 자료

[해피CGI][cgimall] table2excel - jQuery 로 HTML을 EXCEL 로 변환하기

해피CGI윤실장 2025. 6. 27. 09:15

table2excel은 HTML 테이블 데이터를 Excel 파일로 내보낼 수 있는 간단하면서도 유용한 jQuery 플러그인입니다.
라이센스는 MIT 입니다.








# 사용방법 안내

1. HEAD 에 라이브러리 추가

<script src="../dist/jquery.table2excel.js"></script>



2. 내보내기 버튼을 추가하여 테이블 데이터를 EXCEL 파일로 수동 다운로드하기 (선택사항)

<button>Export</button>



3. 다운로드 버튼 클릭 시 변환할 테이블을 플러그인과 연결

<SCRIPT>
$("button").click(function(){
  $("#table2excel").table2excel({
    // exclude CSS class
    exclude: ".noExl",
    name: "Worksheet Name",
    filename: "SomeFile", //do not include extension
    fileext: ".xls" // file extension
  });
});
</SCRIPT>




4. CSS 클래스 'noExl' 를 모든 tr에 추가하여 내보내는 동안 지정된 테이블 데이터를 무시하기

<tr class="noExl">
    <th>#</th>
    <th>Column heading</th>
    <th>Column heading</th>
    <th>Column heading</th>
</tr>




# 추가 옵션

preserveColors : 배경색, 글꼴색 유지 옵션을 유지할 수 있습니다. (기본값 false)

exclude_links : 링크를 유지할 수 있습니다. (기본값 true)
exclude_inputs : 입력필드를 제외할지 여부를 설정할 수 있습니다. (기본값 true)

 

Comments