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

IE10 Support (reader.readAsBinaryString) #22

Closed
SKALIDHASAN opened this issue Apr 13, 2013 · 2 comments
Closed

IE10 Support (reader.readAsBinaryString) #22

SKALIDHASAN opened this issue Apr 13, 2013 · 2 comments

Comments

@SKALIDHASAN
Copy link

I have trouble reading the Uploaded File (XLSX) via FileReader API's "readAsBinaryString" method in IE10. "readAsText" method works fine. Has anyone come across this, does IE support this method? Am I missing something. Pls find the snippet below:

function handleFileUpload(evt){

    evt.stopPropagation();
    evt.preventDefault();

    var files = (evt.target.files || evt.dataTransfer.files);
    var output = [];

    for (var i = 0, f; f = files[i]; i++) { 
        output.push('<li><strong>', escape(f.name), '</strong> (', f.type || 'n/a', ') - ', f.size, '   bytes, last modified: ', f.lastModifiedDate ?                                   
        f.lastModifiedDate.toLocaleDateString() :   'n/a', '</li>');

        var reader = new FileReader();
        reader.onload = function(e) {
            var data = e.target.result;
            alert("-- Data Length --" + data.length);
    };

         // Read in the XLSX file in Binary Mode.   
         //reader.readAsBinaryString(f);//<-- does not work if this method is used in IE10 (10.0.9200.16540C0), but works on Chrome     
           reader.readAsText(f);//<-- Works on both Chrome & IE10 (10.0.9200.16540C0)

    }//for 

}//handleFileUpload
@redchair123
Copy link

IE10 does not support readAsBinaryString. To test on IE I have been using
the Base64 method (generating the input and pasting into the text box).

FYI in this case readAsArrayBuffer is probably better.

I've also been looking for a more general solution that also works with
older IEs (using something like flash or silver light).

On Saturday, April 13, 2013, SKALIDHASAN wrote:

I have trouble reading the Uploaded File (XLSX) via FileReader API's
"readAsBinaryString" method in IE10. "readAsText" method works fine. Has
anyone come across this, does IE support this method? Am I missing
something. Pls find the snippet below:

function handleFileUpload(evt){

evt.stopPropagation();
evt.preventDefault();

var files = (evt.target.files || evt.dataTransfer.files);
var output = [];

for (var i = 0, f; f = files[i]; i++) {
output.push('

  • ', escape(f.name), ' (', f.type || 'n/a', ') - ', f.size, ' bytes, last modified: ', f.lastModifiedDate ?
    f.lastModifiedDate.toLocaleDateString() : 'n/a', '
  • ');

    var reader = new FileReader();
    reader.onload = function(e) {
        var data = e.target.result;
        alert("-- Data Length --" + data.length);
    

    };

     // Read in the XLSX file in Binary Mode.
     //reader.readAsBinaryString(f);//<-- does not work if this method is used in IE10 (10.0.9200.16540C0), but works on Chrome
       reader.readAsText(f);//<-- Works on both Chrome & IE10 (10.0.9200.16540C0)
    

    }//for

    }//handleFileUpload


    Reply to this email directly or view it on GitHubhttps://github.com//issues/22
    .

    @redchair123
    Copy link

    @SKALIDHASAN I pushed a change so it works on IE10 (I also had to handle the 'dragenter' event). At a later time, I'll add support for older IEs

    clarketm pushed a commit to clarketm/js-xlsx that referenced this issue Nov 27, 2016
    mikeleo pushed a commit to FoundPlaces/js-xlsx that referenced this issue Mar 22, 2018
    Adds basic support for writing out formulas
    @SheetJS SheetJS locked and limited conversation to collaborators Feb 22, 2023
    Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants