Ich möchte extjs Grid-Inhalt in Excel-Datei exportieren. Also, was ich bereits getan haben: i an das Servlet json Inhalt des Gitters durch Ext.Ajax.request senden, wieExport Excel von extjs Grid
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);
}
});
Dann in Servlet i json in Servlet bekommen ein paar Sachen zu tun, zum Beispiel Erstellen Sie Excel-Datei, konvertieren Sie es in Byte-Array und versuchen Sie, in Antwort zu setzen. In Ext.Ajax.request in Erfolg Methode, wenn ich versuche, so etwas zu tun:
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();
es Downloads Excel-Datei, aber wenn ich es öffnen Fehler auftritt, sagen Format oder Erweiterung ist ungültig.
WARUM? Ob es von der Codierung abhängen kann? Was mache ich falsch?