Skip to content

Commit

Permalink
Edge support added
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrn committed Mar 18, 2019
1 parent 0720081 commit 1fde35d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filefy",
"version": "0.1.8",
"version": "0.1.9",
"description": "A javascript library to produce downloadable files sucs as in CSV, PDF, XLSX, DOCX formats",
"main": "./dist/index.js",
"homepage": "https://github.com/mbrn/filefy#readme",
Expand Down
24 changes: 16 additions & 8 deletions src/core/BaseBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
export default class BaseBuilder {
protected exportFile(dataType: string, fileName: string, data: string) {
var charBom = "\uFEFF";
var encodedData = encodeURIComponent(data);
let content = `data:text/${dataType};charset=utf-8,${charBom}${encodedData}`;

var link = document.createElement("a");
link.setAttribute("href", content);
link.setAttribute("download", fileName);
document.body.appendChild(link);

link.click();
if (window.navigator.msSaveOrOpenBlob) {
var blob = new Blob([data]);
window.navigator.msSaveOrOpenBlob(blob, fileName);
}
{
var charBom = "\uFEFF";
var encodedData = encodeURIComponent(data);
let content = `data:text/${dataType};charset=utf-8,${charBom}${encodedData}`;

var link = document.createElement("a");
link.setAttribute("href", content);
link.setAttribute("download", fileName);
document.body.appendChild(link);

link.click();
}
}
}

0 comments on commit 1fde35d

Please sign in to comment.