2016-07-26 10 views
0

엑셀 파일로 extjs 그리드 내용을 내보내려고합니다. 그래서 난 이미 수행 한 : 내가 Ext.Ajax.request을 통해 그리드의 서블릿 json으로 콘텐츠를 전송, 내가 서블릿에서 몇 가지 물건을 JSON을 얻을 서블릿에서 다음extjs 그리드에서 엑셀 내보내기

Ext.Ajax.request({ 
     url : 'ExportToExcel', 
     method:'POST', 
     jsonData: this.store.proxy.reader.rawData, 
     scope : this, 
     success : function(response,options) { 
      this.onExportSuccess(response, options); 
     }, 
     //method to call when the request is a failure 
     failure: function(response, options){ 
      alert("FAILURE: " + response.statusText); 
     } 
    }); 

, 예를 들어, 같은 파일을 생성하고 바이트 배열로 변환 한 다음 응답을 시도합니다.

var blob = new Blob([response.responseText], { type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet}); 

var downloadUrl = window.URL.createObjectURL(blob); 
var a = document.createElement("a"); 
a.href = downloadUrl; 
a.download = filename; 
document.body.appendChild(a); 
a.click(); 

이 다운로드 파일을 엑셀,하지만 난 그것을 열 때 오류가 형식이나 확장자가 유효하지 말, 발생 성공 방법 Ext.Ajax.request에서 은 내가 이런 식으로 뭔가를하려고 할 때.

왜? 인코딩 여부에 따라 달라질 수 있습니까? 내가 뭘 잘못하고있어?

답변

0

내선는 내장 엑셀 수출되어 당신은 당신이 원하는 결과 툴킷에서

grid.saveDocumentAs({ 
    type: 'excel', 
    title: 'My Excel Title', 
    fileName: 'MyExcelFileName.xml' 
}); 

얻을 수 있는지 확인하기 위해 그것을 사용하려고 할 수 있습니다. Ext.grid.plugin.Exporter

관련 문제