2016-07-26 5 views
0

extjsグリッドの内容をエクセルファイルにエクスポートしたい。だから私はすでに何をした: iはエクセルエクセルから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); 
     } 
    }); 

のように、Ext.Ajax.requestを通じてグリッドのサーブレットJSONコンテンツに送る次にサーブレットに私は、例えば、いくつかのものを行うサーブレットでJSONを取得しますexcelファイルを作成し、バイト配列に変換して応答に入れようとします。成功の方法でExt.Ajax.requestで 私はこのような何かをしよう:形式または拡張子が無効であると言って、

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(); 

それのダウンロードには、Excelファイルが、私はそれを開いたときにエラーが発生します。

WHY ?? エンコードに依存するかどうか 私は間違っていますか?

答えて

0

内線が組み込まExcelの輸出が付属していますあなたが望む結果Toolkitの

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

得るかどうかを確認するためにそれを使用して試してみたいことがあります。。Ext.grid.plugin.Exporter

関連する問題