PureJS excelio blob 질문
페이지 정보
작성자 111214 작성일 2023-10-04 15:08 조회 213회 댓글 0건본문
관련링크
excelio 의 open 을 사용하여 엑셀파일의 내용을 보여주려고 하는데
{errorCode: 1, errorMessage: 'Incorrect file format.'} 이 발생합니다.
혹시나 테스트중인 로컬에서 파일을 가져올때 문제가 되나 싶어서 해당 파일을 다운로드 했을경우에는 정상적으로 파일이 다운로드 됩니다.
back-end 에서 파일정보는 byte array로 보내주고 jsp 에서 blob으로 변환하여 사용하려고 하는데
해당 메시지가 발생할 경우에는 어느부분을 좀더 확인해봐야 할까요
아래에는 jsp 로직 첨부합니다.
$.ajax({
type: "get",
dataType: "json",
async: false,
url: pageContextPath + "/preDvr/getExcelView",
data: {
"seq": "3081",
"fileId": "0f9cb920",
"fileName": "export_20230831_01.xlsx",
"fileExtension": "xlsx"
}
}).done(function(result) {
console.log("result : ", result);
if(result.issuccess) {
// var blob = new Blob([result.data], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
var blob = b64toBlob(result.data,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
console.log(blob);
excelIo.open(blob, json => {
console.log("json : ", json);
spread.formJSON(json, {
doNotRecalculateAfterLoad: true
});
}, message =>{
console.log("message : ", message);
});
//파일다운로드 추가해봄
var downloadUrl = URL.createObjectURL(blob);
var a = document.createElement("a");
a.href = downloadUrl;
a.download = "import_excel.xlsx"
document.body.appendChild(a);
a.click();
} else {
alert("조회에 실패했습니다.");
}
}).fail(function(xhr, status, errorThrown) {
alert("조회에 실패하였습니다.");
console.log(xhr);
})
댓글목록
등록된 댓글이 없습니다.