-
[axios] 엑셀 파일 다운로드 기능 구현하기쬬는 개발중 2022. 12. 4. 12:26반응형
엑셀 파일 다운로드
javascript 를 사용하여 a 태그에 받은데이터를 넣어서 동작 구현이 가능하다.
api에 속성과 입력값에 따라 params 값을 설정해주고 responseType 을 설정해준다
axios({ url: "/report", methods: "GET", params: { year: this.year, month: this.month, xls: "Y", xlsLimit: "300" }, responseType: "blob" //responseType 설정 }).then(res => { const url = window.URL.createObjectURL(new Blob([res.data])); const link = document.createElement("a"); link.href = url; link.setAttribute("download", 설정할 이름 + ".xlsx"); document.body.appendChild(link); link.click(); });
반응형'쬬는 개발중' 카테고리의 다른 글
[javascript] 모바일 검색창 숨기기 기능 구현 (터치 떨림 보정) (1) 2023.01.30 masonry / infinite scroll / imagesLoaded 활용하여 핀터레스트 | 네이버 이미지 리스트화면 구현하기 (0) 2022.12.09 [axios] 이미지 POST 기능이 제대로 동작하지 않을때 확인사항 (0) 2022.12.02 [javascript | Vue] 이미지 다운로드 기능 만들기 (canvas/url활용) (0) 2022.12.02 [javascript] 문자 /n 줄바꿈 변환작업 (1) 2022.12.02