mirror of
https://github.com/shuchkin/simplexlsxgen.git
synced 2023-08-10 21:12:59 +03:00
1.2.15
This commit is contained in:
parent
053574d1e1
commit
aef6ee4935
28
README.md
28
README.md
@ -131,17 +131,29 @@ function array2excel() {
|
|||||||
|
|
||||||
var request = new XMLHttpRequest();
|
var request = new XMLHttpRequest();
|
||||||
|
|
||||||
request.onreadystatechange = function () {
|
request.onload = function () {
|
||||||
if (this.readyState === 4) {
|
if (this.status === 200) {
|
||||||
if (this.status === 200) {
|
var file = new Blob([this.response], {type: this.getResponseHeader('Content-Type')});
|
||||||
var file = new Blob([this.response], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
|
var fileURL = URL.createObjectURL(file);
|
||||||
var fileURL = URL.createObjectURL(file);
|
var filename = "", m;
|
||||||
window.open(fileURL);
|
var disposition = this.getResponseHeader('Content-Disposition');
|
||||||
} else {
|
if (disposition && (m = /"([^"]+)"/.exec(disposition)) !== null) {
|
||||||
alert("Error: " + this.status + " " + this.statusText);
|
filename = m[1];
|
||||||
}
|
}
|
||||||
|
var a = document.createElement("a");
|
||||||
|
if (typeof a.download === 'undefined') {
|
||||||
|
window.location = fileURL;
|
||||||
|
} else {
|
||||||
|
a.href = fileURL;
|
||||||
|
a.download = filename;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert("Error: " + this.status + " " + this.statusText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
request.open('POST', "array2excel.php");
|
request.open('POST', "array2excel.php");
|
||||||
request.responseType = "blob";
|
request.responseType = "blob";
|
||||||
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
Loading…
Reference in New Issue
Block a user