Comments (25)
as workaround, On :
function doClick() {
if(window.navigator.msSaveOrOpenBlob) {
var blob = new Blob([scope.csv], {
(...)
I modify the blob creation to decode the CSV again :
var blob = new Blob([decodeURIComponent(scope.csv)]
from ng-csv.
Hi there,
Sorry for the late response, I just returned from a vacation.
Apparently IE doesn't support the "download" attribute yet,
I'll try to find a nice Polyfill or a workaround.
from ng-csv.
same for safari ...
from ng-csv.
thanks to @marcgara IE10+ are supported now,
as for safari, currently I could not find a good solution that will keep this library small
from ng-csv.
Any chance to make it work on IE9 ?
from ng-csv.
I've just give it a try on IE10, the generated CSV file is wrong. Instead of a multi-line CSV file, there is single continuous line.
from ng-csv.
What version did you use ?
I released a new version few days ago that should fix it
from ng-csv.
0.2.3 and 0.2.2.
Also I did not understand why is the encoding necessary. The content is already in the browser what is the purpose of encodeURIComponent()?
On Firefox the file is OK, but on IE10, space characters are encoded as %20.
from ng-csv.
Probably IE is not complient with the data uri standard,
I'm not sure what you mean by "already in the browser", but you have to encode your data in order to use data uri correctly, please go over this, it should clear it out for you.
Anyway, I'll go over the IE behavior.
from ng-csv.
@bingenortuzar Work perfectly, thank
from ng-csv.
Do you want to pull request your patch ?
from ng-csv.
Done (or at least I think so :) )
from ng-csv.
Hi,
update helped exporting valid CSV in IE but still encoding is not working as in other browser. I'm using add-bom so it opens correctly in Excel and it's not working in IE. Probably BOM is broken when exporting from IE.
from ng-csv.
I haven't released a new version yet. have you tried using the latest source code ?
from ng-csv.
Yes I added "var blob = new Blob([decodeURIComponent(scope.csv)],{" change from last pull request. It made it produce valid CSV in IE but looks like BOM is missing although I'm using add-bom.
from ng-csv.
Thank you very much for this directive .I used the latest updated version.
Its working well with ie9+. For ie9, file does not download .Any fix for ie9?
from ng-csv.
@barbecube I don't need BOOM, and no time now to try, but looking into code, saw:
if(window.navigator.msSaveOrOpenBlob) {
csv = csvContent;
}else{
csv = DATA_URI_PREFIX;
if (options.addByteOrderMarker){
csv += BOM;
}
csv += csvContent;
}
def.resolve(csv);
});
as you can see, the BOOM is not included for Blob downloads.
perhaps changing to this could work (NOT PROBED, just saying):
if(!window.navigator.msSaveOrOpenBlob) {
csv = DATA_URI_PREFIX;
}
else
{
csv = ''
}
if (options.addByteOrderMarker){
csv += BOM;
}
csv += csvContent;
def.resolve(csv);
});
from ng-csv.
Working with fix like as below? ng-csv not working in my IE.
var blob = new Blob([decodeURIComponent(scope.csv)],{
if(!window.navigator.msSaveOrOpenBlob) {
csv = DATA_URI_PREFIX;
}else{
csv = ''
}
if (options.addByteOrderMarker){
csv += BOM;
}
csv += csvContent;
def.resolve(csv);
from ng-csv.
nop!
the idea (and is just that, an idea) is to replace the "if(window.navigator.msSaveOrOpenBlob) {..." that starts on line 119 of ng-csv.js
from ng-csv.
Sorry for my late response, easy to miss comments in a closed pull request.
I just released a new version that should fix the BOM issues with IE.
from ng-csv.
for download attribut: http://caniuse.com/#search=download%20attribute
if somebody is interrested by using ng-csv supported by all bowser (also ie<10)
link: function (scope, element, attrs) {
function doClick() {
if (window.navigator.msSaveOrOpenBlob) {
var blob = new Blob([decodeURIComponent(scope.csv)], {
type: "text/csv;charset=utf-8;"
});
navigator.msSaveBlob(blob, scope.getFilename());
} else {
if (window.navigator.appName === 'Microsoft Internet Explorer') {
var iframe = angular.element('<iframe></iframe>');
iframe[0].style.display = "none";
element.append(iframe);
var doc = null;
if (iframe[0].contentDocument)
doc = iframe[0].contentDocument;
else if (iframe[0].contentWindow)
doc = iframe[0].contentWindow.document;
doc.open("text/plain", "replace");
doc.write([decodeURIComponent(scope.csv)]);
doc.close();
//iframe.focus();
doc.execCommand('SaveAs', true, scope.getFilename());
} else {
var downloadLink = angular.element('<a></a>');
downloadLink.attr('href', scope.csv);
downloadLink.attr('download', scope.getFilename());
$document.find('body').append(downloadLink);
$timeout(function () {
downloadLink[0].click();
downloadLink.remove();
}, null);
}
}
}
element.bind('click', function (e) {
scope.buildCSV().then(function (csv) {
doClick();
});
scope.$apply();
});
}
from ng-csv.
Hi BerangereMartin,
Can you provide as a plunker , on how to used code , you have provided
Thanks
from ng-csv.
Same issue here. I am trying to use this directive in IE9. Doesn't work. Can someone post a plunker with the hack they did to make it work?
from ng-csv.
See my pull request i am sorry but no Time to make a plunker
from ng-csv.
Is this fix being merged soon?
Otherwise I'd be happy to provide a new pull request. We've made it work in IE9 as well.
Pull request: #150
from ng-csv.
Related Issues (20)
- JSON/JS array format HOT 3
- cannot use Promise to retrieve header HOT 1
- ng-csv perforamance with large number of dataset
- do you know the MIME type of the download
- Ignore columns of type object HOT 1
- .bind instead of .on
- Problem with BOM and Saving files in Excel HOT 1
- Create default options object when none is provided
- leading zeros for string field
- safari can't download csv file HOT 2
- generate object HOT 2
- How to use "text delimiter" attribute?
- Save As? HOT 1
- Field with leading zeros being treated as a number rather than a string HOT 1
- Labels options requires all objects to have all keys present
- ng-csv not supported in Edge
- Issues in Chrome 65 HOT 14
- Not downloading on current window
- How to add more than one header? HOT 2
- Cant add txtDelim when the seprator is not equals to (,) without setting quoteStrings to true
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ng-csv.