본문 바로가기

개발중/JavaScript

js 에서 액셀 파일 샘플 (excel sample) 생성하기

728x90
반응형

xlsx 를 서버에서 poi 로 생성하려는 고정 관념이 너무세개 박혔었다.

이 두개면 충분 할 것을 ;;;

 

참고

 

npm install xlsx file-saver -S
npm install script-loader -S -D

 

, async downloadByQuestionExcelSample (){

    import('@/vendor/Export2Excel').then(excel => {
        const tHeader = ['Id', 'Title', 'Author', 'Readings', 'Date']
        const filterVal = ['id', 'title', 'author', 'pageviews', 'display_time']
        const list = [{id : 1, title : 'binsoo' , author : 's' , pageviews : 0, display_time : 3303 }]
        const data = this.formatJson(filterVal, list)
        excel.export_json_to_excel({
          header: tHeader,
          data,
          filename: this.filename,
          autoWidth: this.autoWidth,
          bookType: this.bookType
        })
      })
    }
    , formatJson(filterVal, jsonData) {
      return jsonData.map(v => filterVal.map(j => {
        if (j === 'timestamp') {
          return parseTime(v[j])
        } else {
          return v[j]
        }
      }))
    }

🖤 글이 도움이 되었다면 유튜브 클릭 해주세요 🖤
https://www.youtube.com/channel/UCgkxlLdjrlsFyp2GGxzY59A
 

디벨빈수

안녕하세요. 저는 2년차 #비전공자 #풀스택 #개발자 빈수 입니다. ლ(╹◡╹ლ) .. 구독 댓글과 좋아요 알림 설정 감자합니다. - 개발 블로그 : https://soobindeveloper8.tistory.com/ - 깃허브 : https://github.com

www.youtube.com

 


 

728x90
반응형