React에서 table Element를 엑셀 파일로 다운로드하는 방법에 대해 설명합니다.
react-html-table-to-excel 사용
공식 사이트 : https://www.npmjs.com/package/react-html-table-to-excel
특징
- HTML <Table>...</Table>을 .xls 형식의 Excel 파일로 다운로드
- IE 11 지원
설치
npm install --save react-html-table-to-excel
Import
import ReactHTMLTableToExcel from 'react-html-table-to-excel';
코드
See the Pen TableToExcel by JaeSung2386 (@jaesung2386) on CodePen.
다운로드한 엑셀 파일
react-html-table-to-excel Moudle의 장점은 table Element의 id와 ReactHTMLTableToExcel 컴포넌트의 table Property를 매핑해주면 table 엘리먼트의 데이터들을 자동으로 엑셀로 다운로드해주는 장점이 있습니다.
단점으로는 table 엘리먼트 내부의 데이터를 가공하거나 .csv 형식 또는 .xlsx 형식으로 다운로드는 불가능합니다.
반응형
'React > 유용한 NPM' 카테고리의 다른 글
[React]React에서 Sass 사용 (0) | 2021.11.02 |
---|---|
[React]조건문 작성 방법 (0) | 2021.11.02 |
[React]Recoil 간단한 예제 코드 (0) | 2021.07.25 |
[React]csv 파일로 다운로드 (0) | 2021.07.13 |
[React]현재 브라우저 정보 확인하기 (0) | 2021.07.13 |
댓글