file Download

Jinmin Kim·2023년 11월 8일
        let blob = new Blob([file], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
        let fileSplit = file?.name.split(".");
        let fileName = fileSplit.splice(0, fileSplit.length - 1)
            .join();

        if (window.navigator && window.navigator.msSaveOrOpenBlob) { // for IE
            window.navigator.msSaveOrOpenBlob(blob, fileName+ ".xlsx");
        } else {  // for Non-IE (chrome, firefox etc.)
            let fileUrl = window.URL.createObjectURL(blob);
            let a = document.createElement('a');

            a.style = "display: none";
            a.href = fileUrl;
            a.download =  fileName + ".xlsx"; //orgFileName;
            a.click();
            window.URL.revokeObjectURL(fileUrl);
        }
profile
Let's do it developer

0개의 댓글