반응형
vue 프로젝트에서 blob 및 FileSaver.js를 사용하여 excel(.xlsx)을 다운로드하고 있습니다.
Vue 프로젝트에서 API 요청을 전송하여 파일을 다운로드하려고 합니다.응답 데이터로 blob과 FileSaver.js를 사용하여 파일을 저장하려고 합니다.
sendAjaxCall.then(response => {
let file = new Blob([response.data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
FileSaver.saveAs(file, 'Export2.xlsx')
}
하지만 파일이 손상되어 파일을 열 수 없습니다.
이거 먹어봐
return Vue.axios.get(`api/excel_sheet`, {
responseType: 'blob',
}).then(response => {
FileSaver.saveAs(response.data, 'Export2.xlsx')
};
응답 유형을 blob으로 지정해야 합니다.
언급URL : https://stackoverflow.com/questions/48181594/downloading-excel-xlsx-with-blob-and-filesaver-js-in-vue-project-getting-corup
반응형
'itsource' 카테고리의 다른 글
(리터럴 방식으로) HashMap을 직접 초기화하려면 어떻게 해야 합니까? (0) | 2022.08.29 |
---|---|
nuxt에서 vue-chartjs에서 이 오류가 발생하는 이유는 무엇입니까? (0) | 2022.08.29 |
Vuex를 사용하여 데이터베이스에서 상태를 처음 로드하는 시기 (0) | 2022.08.29 |
뮤텍스 예/자습서? (0) | 2022.08.29 |
char의 길이는 정확히 8비트입니까? (0) | 2022.08.29 |