Skip to content

Commit

Permalink
Found the real problem with blob and fixed it using blob.
Browse files Browse the repository at this point in the history
in firefox you have to append element before clicking on it unlike chrome.
also there was a problem with UTF-8 char-set, fixed it by adding UTF-8 BOM at the beginning of file.
  • Loading branch information
rzvxa committed Jun 13, 2018
1 parent 4c6da1a commit 63e9be1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions dist/js/jquery.jexcel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3862,14 +3862,14 @@ var methods = {
data += $(this).jexcel('copy', false, ',', true);

// Download elment
var a = $('<a>');
a.attr('download', options.csvFileName + '.csv');
a.attr('href', 'data:text/csv;charset=utf-8,\uFEFF' + encodeURIComponent(data));
a.attr('target', '_blank');
a.hide();
$('body').append(a);
a[0].click();
a.remove();
var pom = document.createElement('a');
var blob = new Blob(["\uFEFF"+data], {type: 'text/csv;charset=utf-8;'});
var url = URL.createObjectURL(blob);
pom.href = url;
pom.setAttribute('download', options.csvFileName + '.csv');
document.body.appendChild(pom);
pom.click();
document.body.removeChild(pom);
},

/**
Expand Down

0 comments on commit 63e9be1

Please sign in to comment.