Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE Compatibility #3

Closed
mcadelago opened this issue Oct 25, 2013 · 25 comments
Closed

IE Compatibility #3

mcadelago opened this issue Oct 25, 2013 · 25 comments
Labels

Comments

@mcadelago
Copy link

Nice little directive! However, it doesn't seem to be working in internet explorer at the moment. Is there any plan to modify it to work for IE?

@asafdav
Copy link
Owner

asafdav commented Nov 13, 2013

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.

@akatreyt
Copy link

same for safari ...

asafdav added a commit that referenced this issue May 22, 2014
Should Fix IE Compatibility #3
@asafdav
Copy link
Owner

asafdav commented Jun 2, 2014

thanks to @marcgara IE10+ are supported now,
as for safari, currently I could not find a good solution that will keep this library small

@padsbanger
Copy link

Any chance to make it work on IE9 ?

@cr0man
Copy link

cr0man commented Jul 16, 2014

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.

@asafdav
Copy link
Owner

asafdav commented Jul 17, 2014

What version did you use ?
I released a new version few days ago that should fix it

@cr0man
Copy link

cr0man commented Jul 17, 2014

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.

@asafdav
Copy link
Owner

asafdav commented Jul 20, 2014

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.

@bingenortuzar
Copy link

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)]

@Aldorus
Copy link

Aldorus commented Oct 31, 2014

@bingenortuzar Work perfectly, thank

@asafdav
Copy link
Owner

asafdav commented Oct 31, 2014

Do you want to pull request your patch ?

@bingenortuzar
Copy link

Done (or at least I think so :) )

@barbecube
Copy link

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.

@asafdav
Copy link
Owner

asafdav commented Nov 6, 2014

I haven't released a new version yet. have you tried using the latest source code ?

@barbecube
Copy link

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.

@iammanusharma
Copy link

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?

@bingenortuzar
Copy link

@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);
});

@inska
Copy link

inska commented Nov 20, 2014

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);

@bingenortuzar
Copy link

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

@asafdav
Copy link
Owner

asafdav commented Nov 25, 2014

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.

@BerangereMartin
Copy link

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();
                    });
                }

@Rmabini
Copy link

Rmabini commented May 4, 2015

Hi BerangereMartin,

Can you provide as a plunker , on how to used code , you have provided

Thanks

@chaitujil
Copy link

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?

@BerangereMartin
Copy link

See my pull request i am sorry but no Time to make a plunker

@lcampanis
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests