본문 바로가기
IT관련/REACT

react에서 Html을 docx파일로 받기(Html -> docx 변환)

by 양평 대저택 2020. 12. 9.

- 패키지 설치

npm install html-docx-js-typescript --save-dev

 

- include

import { asBlob } from 'html-docx-js-typescript'

// if you want to save the docx file, you need

import 'file-saver' import { saveAs } from 'file-saver'

 

 

- 예제

handleClickWordSaveButton = () => {

 

asBlob('html data').then(data => {

   saveAs(data, '문서명' + '.docx') // save as docx file

   }) // asBlob() return Promise

}

 

 

"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."

- 참고

github.com/caiyexiang/html-docx-js-typescript

 

caiyexiang/html-docx-js-typescript

Convert HTML documents to docx format. Contribute to caiyexiang/html-docx-js-typescript development by creating an account on GitHub.

github.com