Support for Older Browsers (IE8) #88

Closed
opened 2014-07-21 22:42:50 +00:00 by wintersm · 14 comments
wintersm commented 2014-07-21 22:42:50 +00:00 (Migrated from github.com)

I have been at it for a full day now with no luck, so I am turning to you(all) for help.

I am a mechanical engineer with an interest in coding. I am trying to parse data from an excel spreadsheet. Right now I don't think I care if it is XLS, XLSX, or XLSM. My roadblock appears to be my browser. I am working with IE8, running server-side Javascript.

Up until now, I was working with an excel file that automatically generated CSV files at Save, and I was using Javascript to parse the CSV files using XMLHttpRequest(). It seems you have eliminated the need to create extra CSV files.

So, to my point, I believe the fault is fully with me, but I was hoping you could help get my code working. I recognize that IE8 does not support Uint8Array and I need some sort of workaround. From what I can tell, you have already resolved this and I am just not implementing it correctly. I think I need to be working with the Base64 format . . . but I have no idea how to do that. As I understand it, jszip.js will do that for me and I just have to figure out how to do that. I thought I read that the shim resolved this issue, but I still get (Uint8Array is underfined).

Thanks for any help!

Here is my code, which is really your code with paths to your libraries:

<doctype html>
<html>
<head>
</head>
<script lang="javascript" src="Include/shim.js"></script>
<script lang="javascript" src="https://github.com/SheetJS/js-xlsx/dist/xlsx.core.min.js"></script>

    <script>

    /* set up XMLHttpRequest */
    var url = "test.xlsx";
    var oReq = new XMLHttpRequest();
    oReq.open("GET", url, true);
        oReq.responseType = "arraybuffer";

    oReq.onreadystatechange = function(e) {
        var arraybuffer = oReq.response;

        /* convert data to binary string */
        var data = new Uint8Array(arraybuffer);
        var arr = new Array();
        for(var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]);
        var bstr = arr.join("");

        /* Call XLS */
        var workbook = XLS.read(bstr, {type:"binary"});

        /* DO SOMETHING WITH workbook HERE */
    }

    oReq.send();

    </script>
<body>
</body>
</html>
I have been at it for a full day now with no luck, so I am turning to you(all) for help. I am a mechanical engineer with an interest in coding. I am trying to parse data from an excel spreadsheet. Right now I don't think I care if it is XLS, XLSX, or XLSM. My roadblock appears to be my browser. I am working with IE8, running server-side Javascript. Up until now, I was working with an excel file that automatically generated CSV files at Save, and I was using Javascript to parse the CSV files using XMLHttpRequest(). It seems you have eliminated the need to create extra CSV files. So, to my point, I believe the fault is fully with me, but I was hoping you could help get my code working. I recognize that IE8 does not support Uint8Array and I need some sort of workaround. From what I can tell, you have already resolved this and I am just not implementing it correctly. I think I need to be working with the Base64 format . . . but I have no idea how to do that. As I understand it, jszip.js will do that for me and I just have to figure out how to do that. I thought I read that the shim resolved this issue, but I still get (Uint8Array is underfined). Thanks for any help! Here is my code, which is really **your** code with paths to your libraries: ``` HTML <doctype html> <html> <head> </head> <script lang="javascript" src="Include/shim.js"></script> <script lang="javascript" src="https://github.com/SheetJS/js-xlsx/dist/xlsx.core.min.js"></script> <script> /* set up XMLHttpRequest */ var url = "test.xlsx"; var oReq = new XMLHttpRequest(); oReq.open("GET", url, true); oReq.responseType = "arraybuffer"; oReq.onreadystatechange = function(e) { var arraybuffer = oReq.response; /* convert data to binary string */ var data = new Uint8Array(arraybuffer); var arr = new Array(); for(var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]); var bstr = arr.join(""); /* Call XLS */ var workbook = XLS.read(bstr, {type:"binary"}); /* DO SOMETHING WITH workbook HERE */ } oReq.send(); </script> <body> </body> </html> ```
SheetJSDev commented 2014-07-21 23:21:53 +00:00 (Migrated from github.com)

It saddens me to hear that you spent a full day at this before reaching out :/ we don't bite (or at least I haven't been known to bite) and I hope that we haven't given any impression that we don't like to answer questions. I am not in front of a computer, but it looks like the README links to an example at http://oss.sheetjs.com/js-xlsx/ajax.html . Does that work for you? To be honest, I really wouldn't be surprised if it didn't work -- I don't recall testing it on IE8. To clarify what is meant by supporting older browsers: I tested with small workbooks using the base64 mode at http://oss.sheetjs.com/js-xls and http://oss.sheetjs.com/js-xlsx . I have not tested the other demos in IE 8 (which is why asking questions earlier is better :) and most likely IE8 doesn't support some XHR feature that the demo uses. If the demo doesn't work, let me know and I'll take a look in a few hours.

On Jul 21, 2014, at 6:42 PM, wintersm notifications@github.com wrote:

I have been at it for a full day now with no luck, so I am turning to you(all) for help.

I am a mechanical engineer with an interest in coding. I am trying to parse data from an excel spreadsheet. Right now I don't think I care if it is XLS, XLSX, or XLSM. My roadblock appears to be my browser. I am working with IE8, running server-side Javascript.

Up until now, I was working with an excel file that automatically generated CSV files at Save, and I was using Javascript to parse the CSV files using XMLHttpRequest(). It seems you have eliminated the need to create extra CSV files.

So, to my point, I believe the fault is fully with me, but I was hoping you could help get my code working. I recognize that IE8 does not support Uint8Array and I need some sort of workaround. From what I can tell, you have already resolved this and I am just not implementing it correctly. I think I need to be working with the Base64 format . . . but I have no idea how to do that. As I understand it, jszip.js will do that for me and I just have to figure out how to do that. I thought I read that the shim resolved this issue, but I still get (Uint8Array is underfined).

Thanks for any help!

Here is my code, which is really your code with paths to your libraries:

<html> <head> </head>
<script>

/* set up XMLHttpRequest */
var url = "test.xlsx";
var oReq = new XMLHttpRequest();
oReq.open("GET", url, true);
    oReq.responseType = "arraybuffer";

oReq.onreadystatechange = function(e) {
    var arraybuffer = oReq.response;

    /* convert data to binary string */
    var data = new Uint8Array(arraybuffer);
    var arr = new Array();
    for(var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]);
    var bstr = arr.join("");

    /* Call XLS */
    var workbook = XLS.read(bstr, {type:"binary"});

    /* DO SOMETHING WITH workbook HERE */
}

oReq.send();

</script>
</html> — Reply to this email directly or view it on GitHub.
It saddens me to hear that you spent a full day at this before reaching out :/ we don't bite (or at least I haven't been known to bite) and I hope that we haven't given any impression that we don't like to answer questions. I am not in front of a computer, but it looks like the README links to an example at http://oss.sheetjs.com/js-xlsx/ajax.html . Does that work for you? To be honest, I really wouldn't be surprised if it didn't work -- I don't recall testing it on IE8. To clarify what is meant by supporting older browsers: I tested with small workbooks using the base64 mode at http://oss.sheetjs.com/js-xls and http://oss.sheetjs.com/js-xlsx . I have not tested the other demos in IE 8 (which is why asking questions earlier is better :) and most likely IE8 doesn't support some XHR feature that the demo uses. If the demo doesn't work, let me know and I'll take a look in a few hours. > On Jul 21, 2014, at 6:42 PM, wintersm notifications@github.com wrote: > > I have been at it for a full day now with no luck, so I am turning to you(all) for help. > > I am a mechanical engineer with an interest in coding. I am trying to parse data from an excel spreadsheet. Right now I don't think I care if it is XLS, XLSX, or XLSM. My roadblock appears to be my browser. I am working with IE8, running server-side Javascript. > > Up until now, I was working with an excel file that automatically generated CSV files at Save, and I was using Javascript to parse the CSV files using XMLHttpRequest(). It seems you have eliminated the need to create extra CSV files. > > So, to my point, I believe the fault is fully with me, but I was hoping you could help get my code working. I recognize that IE8 does not support Uint8Array and I need some sort of workaround. From what I can tell, you have already resolved this and I am just not implementing it correctly. I think I need to be working with the Base64 format . . . but I have no idea how to do that. As I understand it, jszip.js will do that for me and I just have to figure out how to do that. I thought I read that the shim resolved this issue, but I still get (Uint8Array is underfined). > > Thanks for any help! > > Here is my code, which is really your code with paths to your libraries: > > <doctype html> > <html> > <head> > </head> > > <script lang="javascript" src="Include/shim.js"></script> > > <script lang="javascript" src="https://github.com/SheetJS/js-xlsx/dist/xlsx.core.min.js"></script> > > ``` > <script> > > /* set up XMLHttpRequest */ > var url = "test.xlsx"; > var oReq = new XMLHttpRequest(); > oReq.open("GET", url, true); > oReq.responseType = "arraybuffer"; > > oReq.onreadystatechange = function(e) { > var arraybuffer = oReq.response; > > /* convert data to binary string */ > var data = new Uint8Array(arraybuffer); > var arr = new Array(); > for(var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]); > var bstr = arr.join(""); > > /* Call XLS */ > var workbook = XLS.read(bstr, {type:"binary"}); > > /* DO SOMETHING WITH workbook HERE */ > } > > oReq.send(); > > </script> > ``` > > <body> > </body> > </html> > — > Reply to this email directly or view it on GitHub.
wintersm commented 2014-07-22 14:12:19 +00:00 (Migrated from github.com)

Thanks for the fast reply. I am back in front of my computer. I tried the example, in IE8 but had no luck. I have Chrome running as well, which worked fine. I also ran the stress test on IE8 and had no luck. I am able to use XMR to open CSV files. It seems like the trouble is with binary arrays - hence the Base64 workaround. I am not familiar with Base64 and can't find enough detail to even convert an XSL/XLSX/XLSM file to a Base64 string to test it in IE8. Do I just need to call a Base64 encoder from jszip.js?

Thanks again for the help!

I'm okay trying to grind out a solution before calling for help, but I'll try not to wait so long next time . . .

-Mike

Thanks for the **fast** reply. I am back in front of my computer. I tried the example, in IE8 but had no luck. I have Chrome running as well, which worked fine. I also ran the stress test on IE8 and had no luck. I _am_ able to use XMR to open CSV files. It seems like the trouble is with binary arrays - hence the Base64 workaround. I am not familiar with Base64 and can't find enough detail to even convert an XSL/XLSX/XLSM file to a Base64 string to test it in IE8. Do I just need to call a Base64 encoder from jszip.js? Thanks again for the help! I'm okay trying to grind out a solution before calling for help, but I'll try not to wait so long next time . . . -Mike
SheetJSDev commented 2014-07-22 15:51:34 +00:00 (Migrated from github.com)

Let's test the base64 first (to see if there's a library issue or a file issue)

If you don't see output, there is an issue with the library. If you do see output, then we most likely have a problem with actually reading the binary data from the XHR. (I looked into IE8 XHR a little bit and it seems that we'll have to do something more clever to handle binary data. For example, http://miskun.com/javascript/internet-explorer-and-binary-files-data-access/ suggests a few approaches going through VBScript)

Let's test the base64 first (to see if there's a library issue or a file issue) - Go to http://oss.sheetjs.com/js-xlsx/ . You should see a text area that says `... or paste a base64-encoding here`. - Copy the content from https://gist.githubusercontent.com/SheetJSDev/c18988aa66b926dc0aff/raw/8cc0fa3619efed96f71768b67556db4a9894476b/number_format.xlsm.b64 (it's a base64 encoded version of the file https://raw.githubusercontent.com/SheetJS/test_files/master/number_format.xlsm) and paste it in the box - hit "Click here to process the base64 text". You should see some output. If you don't see output, there is an issue with the library. If you do see output, then we most likely have a problem with actually reading the binary data from the XHR. (I looked into IE8 XHR a little bit and it seems that we'll have to do something more clever to handle binary data. For example, http://miskun.com/javascript/internet-explorer-and-binary-files-data-access/ suggests a few approaches going through VBScript)
wintersm commented 2014-07-22 15:58:00 +00:00 (Migrated from github.com)

Just tried it, I do not see output.

I repeated the steps in Chrome and i did see an output.

Not sure if it means anything, but under Advanced Demo Options for IE8, Use Web Workers & Use readAsBinaryString check boxes are grayed out.

-Mike

Just tried it, I do not see output. I repeated the steps in Chrome and i did see an output. Not sure if it means anything, but under Advanced Demo Options for IE8, Use Web Workers & Use readAsBinaryString check boxes are grayed out. -Mike
SheetJSDev commented 2014-07-22 16:13:48 +00:00 (Migrated from github.com)

@wintersm I can reproduce the issue using the IE8 compatibility mode in IE11. It sees all of the worksheet names but the worksheet objects themselves are empty :(

@wintersm I can reproduce the issue using the IE8 compatibility mode in IE11. It sees all of the worksheet names but the worksheet objects themselves are empty :(
wintersm commented 2014-07-22 16:15:42 +00:00 (Migrated from github.com)

Bummer. Not sure I can be much help, but I am available if you need me to test anything.

Bummer. Not sure I can be much help, but I am available if you need me to test anything.
SheetJSDev commented 2014-07-22 16:30:41 +00:00 (Migrated from github.com)

@wintersm can you refresh and test again? The js-xls shim had a definition for Array.isArray but the corresponding entry was missing in the js-xlsx shim

@wintersm can you refresh and test again? The [js-xls shim](https://github.com/SheetJS/js-xls/blob/master/shim.js#L203-L209) had a definition for `Array.isArray` but the corresponding entry was missing in the js-xlsx shim
wintersm commented 2014-07-22 17:24:17 +00:00 (Migrated from github.com)

wow. very impressive. I compared Chrome and IE8 outputs and they are (nearly) identical.

Not sure if this was intentional, but as an example, under Accounting on SHEET 2011:

IE8:

,1,-1.2,12.3,-12.34,123.45,-123.456,1234.567,-1234.5678,12345.6789,-12345.67891

Chrome:

, 1.00 , (1.20) , 12.30 , (12.34) , 123.45 , (123.46) ," 1,234.57 "," (1,234.57) "," 12,345.68 "," (12,345.68) "

wow. very impressive. I compared Chrome and IE8 outputs and they are (nearly) identical. Not sure if this was intentional, but as an example, under Accounting on SHEET 2011: <h3>IE8:</h3> ,1,-1.2,12.3,-12.34,123.45,-123.456,1234.567,-1234.5678,12345.6789,-12345.67891 <h3>Chrome:</h3> , 1.00 , (1.20) , 12.30 , (12.34) , 123.45 , (123.46) ," 1,234.57 "," (1,234.57) "," 12,345.68 "," (12,345.68) "
SheetJSDev commented 2014-07-22 18:01:14 +00:00 (Migrated from github.com)

@wintersm Can you check the ajax demo http://oss.sheetjs.com/js-xlsx/ajax.html again? I added a workaround using VBArray that appears to work in IE8 (tested in IE8 Document Mode from IE11)

As for the formatting, good catch! The culprit is sloppy string character extraction: https://github.com/SheetJS/ssf/blob/master/ssf.js#L566 -- using str[n] to access characters in a string is not supported everywhere.

@wintersm Can you check the ajax demo http://oss.sheetjs.com/js-xlsx/ajax.html again? I added a workaround using VBArray that appears to work in IE8 (tested in IE8 Document Mode from IE11) As for the formatting, good catch! The culprit is sloppy string character extraction: https://github.com/SheetJS/ssf/blob/master/ssf.js#L566 -- using `str[n]` to access characters in a string is not supported everywhere.
wintersm commented 2014-07-22 18:05:57 +00:00 (Migrated from github.com)

negative. Just a blank screen with

JS-XLSX AJAX Demo

at the top.

negative. Just a blank screen with <h4>JS-XLSX AJAX Demo</h4> at the top.
wintersm commented 2014-07-22 18:08:56 +00:00 (Migrated from github.com)

FYI, here is what I'm using:

image

And here is the error I get:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; chromeframe/32.0.1700.107; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E)
Timestamp: Tue, 22 Jul 2014 18:08:07 UTC

Message: VBArray expected
Line: 65
Char: 3
Code: 0
URI: http://oss.sheetjs.com/js-xlsx/ajax.html

FYI, here is what I'm using: ![image](https://cloud.githubusercontent.com/assets/8228727/3662487/e067fe10-11ca-11e4-89a3-7b1d5d3b3985.png) And here is the error I get: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; chromeframe/32.0.1700.107; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E) Timestamp: Tue, 22 Jul 2014 18:08:07 UTC Message: VBArray expected Line: 65 Char: 3 Code: 0 URI: http://oss.sheetjs.com/js-xlsx/ajax.html
wintersm commented 2014-07-28 17:27:20 +00:00 (Migrated from github.com)

Hey, just checking in to see if you have had any luck getting SheetJS to work with IE8. Please let me know if I can help test anything for you.

Thanks.

-Mike

Hey, just checking in to see if you have had any luck getting SheetJS to work with IE8. Please let me know if I can help test anything for you. Thanks. -Mike
SheetJSDev commented 2014-07-28 17:47:53 +00:00 (Migrated from github.com)

@wintersm The recent push (check the gh-pages branch), based on http://stackoverflow.com/a/5913807, appear to work on IE6 and on IE8: http://oss.sheetjs.com/js-xlsx/ajax.html

There are some differences between the IE and chrome rendering, but for those I will track in a new issue

@wintersm The recent push (check the gh-pages branch), based on http://stackoverflow.com/a/5913807, appear to work on IE6 and on IE8: http://oss.sheetjs.com/js-xlsx/ajax.html There are some differences between the IE and chrome rendering, but for those I will track in a new issue
coffeescriptdev commented 2015-08-27 14:45:09 +00:00 (Migrated from github.com)

Hi,
i am using sheetjs to convert excel files to json using file upload. Its working fine in chrome and firefox but not in ie8. Could any one help me in fixing this issue?

Hi, i am using sheetjs to convert excel files to json using file upload. Its working fine in chrome and firefox but not in ie8. Could any one help me in fixing this issue?
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#88
No description provided.