1

I am reading excel file in my JS App. I am using xlsx npm module to read excel file.

But if MobileNumber in file = 9.23052E+8 then how can i convert it back into plain mobile number in javascript?

Here is example code of how i am reading file:

const bstr = evt.target.result;
const wb = XLSX.read(bstr, {type:'binary'});
const wsname = wb.SheetNames[0];
const ws = wb.Sheets[wsname];
const data = XLSX.utils.sheet_to_csv(ws, {header:1});
console.log("Data>>>"+data);

I don't want to tell user to change format of your cells to plain text or numbers. (Sorry but that is a requirement).

Any help would be appreciated.

Noman Ali
  • 3,160
  • 10
  • 43
  • 77
  • Can't you change the excel file's cell display settings before reading in the file? Because Excel just saves the raw data, and display's it in this format based on the settings of the cell. – Luuklag Dec 05 '17 at 11:09

1 Answers1

0

This code resolved my issue:

Object.keys(sheet).forEach(function(s) {
    if(sheet[s].w) {
        delete sheet[s].w;
        sheet[s].z = '0';
    }
});

More on this post:

Noman Ali
  • 3,160
  • 10
  • 43
  • 77