Skip to content

Commit

Permalink
Check for strings that may be interpreted as numbers (fixes SheetJS#2609
Browse files Browse the repository at this point in the history
)
  • Loading branch information
AbhiramTS committed Jan 18, 2023
1 parent 5b4806b commit f2b5fcc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bits/90_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,13 @@ function make_csv_row(sheet/*:Worksheet*/, r/*:Range*/, R/*:number*/, cols/*:Arr
isempty = false;
txt = ''+(o.rawNumbers && val.t == "n" ? val.v : format_cell(val, null, o));
for(var i = 0, cc = 0; i !== txt.length; ++i) if((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34 || o.forceQuotes) {txt = "\"" + txt.replace(qreg, '""') + "\""; break; }
if (parseInt(txt) == txt) txt = "\"" + txt + "\"";
if(txt == "ID") txt = '"ID"';
} else if(val.f != null && !val.F) {
isempty = false;
txt = '=' + val.f; if(txt.indexOf(",") >= 0) txt = '"' + txt.replace(qreg, '""') + '"';
txt = '=' + val.f;
if (parseInt(val.f) == val.f) txt = "\"" + val.f + "\"";
if(txt.indexOf(",") >= 0) txt = '"' + txt.replace(qreg, '""') + '"';
} else txt = "";
/* NOTE: Excel CSV does not support array formulae */
row.push(txt);
Expand Down

0 comments on commit f2b5fcc

Please sign in to comment.