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.

1
  • 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. Commented Dec 5, 2017 at 11:09

1 Answer 1

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:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.