Home » excel » android – getting value 9.777123455E9 instead of 9777123455 from excel sheet

android – getting value 9.777123455E9 instead of 9777123455 from excel sheet

Posted by: admin May 14, 2020 Leave a comment

Questions:

I am working on a project in which i am getting value from excel sheet(in assets android) and reflecting data in list view.
problem is:: phone no is not in proper format.

9.777123455E9 instead of 9777123455

How to&Answers:

When it’s a phone number, you should always store the cell data as text, even if it consists only of digits, since a phone number is no mathematical number and when doing operations on it, you want to treat it as a string of characters (i.e. text).

If you input a phone number that looks to Excel like a mathematical number, it will interpret it as a number and in consequence will do things to it that make sense for numbers, but not necessarily for phone numbers, such as displaying it in scientific format.

To force Excel to treat your number as text, precede it with a single quote (apostrophe) when entering it. That is, enter into the cell:

'9777123455

It will be displayed without the single quote, just as you expect a phone number to be displayed and can be processed as text.

Answer:

double d=9.777123455E9;

    NumberFormat formatter = new DecimalFormat("#");

    System.out.println(d);
    System.out.println(formatter.format(d));

output

9.777123455E9

9777123455

Answer:

E9 simply means multiply by 10^9

Update:

As @blubberdiblub mentioned, for phone numbers, it makes sense to change it to text. But for other cases, If you need to do mathematical operations leaving it in the scientific format works. You can right click on the column name and select formatting option to set the type of data the column will handle (number , text etc). If you want don’t want to change the phone number to text and still see the number, simply increase the width of the column. The number will be shown full (without the “E”).