IE8 and first column #350

Closed
opened 2016-01-13 16:47:19 +00:00 by Aymkdn · 1 comment
Aymkdn commented 2016-01-13 16:47:19 +00:00 (Migrated from github.com)

So, we all know the first column is ignored when using IE8... after a few hours of debugging I found the problem is coming from parse_ws_xml_data(), on the below line:
for(ri = typeof tag.r === 'undefined' ? 0 : 1; ri != cells.length; ++ri) {

It should be:
for(ri = 0; ri != cells.length; ++ri) {

Because there is no comment in the code I don't know why there is this checking... But by changing it, then IE8 is now able to show the first column.

So, we all know the first column is ignored when using IE8... after a few hours of debugging I found the problem is coming from `parse_ws_xml_data()`, on the [below line](https://github.com/SheetJS/js-xlsx/blob/master/xlsx.js#L7454): `for(ri = typeof tag.r === 'undefined' ? 0 : 1; ri != cells.length; ++ri) {` It should be: `for(ri = 0; ri != cells.length; ++ri) {` Because there is no comment in the code I don't know why there is this checking... But by changing it, then IE8 is now able to show the first column.
SheetJSDev commented 2017-02-21 22:34:17 +00:00 (Migrated from github.com)

So it turns out IE does something unexpected with split on regular expressions when the first match is the beginning of a string. To play along, try

javascript:alert(['abcdef'.split(/a/).length,'abcdef'.split("a").length]) // IE
console.log(['abcdef'.split(/a/).length,'abcdef'.split("a").length]) // environments that support console

When you split on a string, which is the second case, both IE and other browsers will correctly generate 2 values: ["", "bcdef"]. For whatever reason, IE is skipping that first value entirely.

The guard 2 lines down should address the case anyway, so your proposed patch is sufficient and will be pushed in the next version. That change works down to IE6:

IE6 ajax demo
So it turns out IE does something unexpected with split on regular expressions when the first match is the beginning of a string. To play along, try ```js javascript:alert(['abcdef'.split(/a/).length,'abcdef'.split("a").length]) // IE console.log(['abcdef'.split(/a/).length,'abcdef'.split("a").length]) // environments that support console ``` When you split on a string, which is the second case, both IE and other browsers will correctly generate 2 values: `["", "bcdef"]`. For whatever reason, IE is skipping that first value entirely. The guard 2 lines down should address the case anyway, so your proposed patch is sufficient and will be pushed in the next version. That change works down to IE6: <img width="643" alt="IE6 ajax demo" src="https://cloud.githubusercontent.com/assets/6070939/23188206/beb7b9a2-f842-11e6-8a6b-b5c16595869f.png">
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#350
No description provided.