Poi parsing Excel floating-point numbers and integer reads

Source: Internet
Author: User
I now do data import, with POI parsing Excel, now encountered a problem, because the POI resolution to the numeric type of data, the default will be converted to double type, I judge if the type is cell_type_numeric, want to do special treatment, now have two questions, ask everybody:
1. This column may have integers, there may also be floating point number, integer, read out, to go to the back of the ". 0", decimal is how much is how many, at present this does not know how to deal with;
2. The second problem is that if, first of all, I'm going to do it by judging if I'm going to end up with a. 0 method, then if the cell is typed as "313463165464146.26" (or even longer), it will become a scientific count, so it's inaccurate to read.

Above, with

Double d = cell.getnumericcellvalue ();
DecimalFormat df = new DecimalFormat ("#.##");
String value = Df.format (d);



To deal with, is to make the scientific count into a normal number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.