Fixed separators on files with \r\n at end of line

fixes #1943
This commit is contained in:
Garrett Luu 2020-06-12 13:05:05 -07:00
parent cdfe678571
commit 5b356e2528
3 changed files with 33 additions and 3 deletions

@ -813,7 +813,17 @@ var PRN = (function() {
var ws/*:Worksheet*/ = o.dense ? ([]/*:any*/) : ({}/*:any*/);
var range/*:Range*/ = ({s: {c:0, r:0}, e: {c:0, r:0}}/*:any*/);
if(str.slice(0,4) == "sep=" && str.charCodeAt(5) == 10) { sep = str.charAt(4); str = str.slice(6); }
if(str.slice(0,4) == "sep=") {
// If the line ends in \r\n
if(str.charCodeAt(5) == 13 && str.charCodeAt(6) == 10 ) {
sep = str.charAt(4); str = str.slice(7);
}
// If line ends in \r OR \n
else if(str.charCodeAt(5) == 13 || str.charCodeAt(5) == 10 ) {
//
sep = str.charAt(4); str = str.slice(6);
}
}
else sep = guess_sep(str.slice(0,1024));
var R = 0, C = 0, v = 0;
var start = 0, end = 0, sepcc = sep.charCodeAt(0), instr = false, cc=0;

@ -7672,7 +7672,17 @@ var PRN = (function() {
var ws/*:Worksheet*/ = o.dense ? ([]/*:any*/) : ({}/*:any*/);
var range/*:Range*/ = ({s: {c:0, r:0}, e: {c:0, r:0}}/*:any*/);
if(str.slice(0,4) == "sep=" && str.charCodeAt(5) == 10) { sep = str.charAt(4); str = str.slice(6); }
if(str.slice(0,4) == "sep=") {
// If the line ends in \r\n
if(str.charCodeAt(5) == 13 && str.charCodeAt(6) == 10 ) {
sep = str.charAt(4); str = str.slice(7);
}
// If line ends in \r OR \n
else if(str.charCodeAt(5) == 13 || str.charCodeAt(5) == 10 ) {
//
sep = str.charAt(4); str = str.slice(6);
}
}
else sep = guess_sep(str.slice(0,1024));
var R = 0, C = 0, v = 0;
var start = 0, end = 0, sepcc = sep.charCodeAt(0), instr = false, cc=0;

12
xlsx.js generated

@ -7574,7 +7574,17 @@ var PRN = (function() {
var ws = o.dense ? ([]) : ({});
var range = ({s: {c:0, r:0}, e: {c:0, r:0}});
if(str.slice(0,4) == "sep=" && str.charCodeAt(5) == 10) { sep = str.charAt(4); str = str.slice(6); }
if(str.slice(0,4) == "sep=") {
// If the line ends in \r\n
if(str.charCodeAt(5) == 13 && str.charCodeAt(6) == 10 ) {
sep = str.charAt(4); str = str.slice(7);
}
// If line ends in \r OR \n
else if(str.charCodeAt(5) == 13 || str.charCodeAt(5) == 10 ) {
//
sep = str.charAt(4); str = str.slice(6);
}
}
else sep = guess_sep(str.slice(0,1024));
var R = 0, C = 0, v = 0;
var start = 0, end = 0, sepcc = sep.charCodeAt(0), instr = false, cc=0;