When Java reads Excel table date type data, it reads 13-12 months-2017, and Excel enters 2017/12/13 or 2017-12-13
And in Excel, the integer type 5,java read out is 5.0.
How can this be all.
Workaround:
Date conversion
Import Org.apache.poi.ss.usermodel.DateUtil;
Import Org.apache.poi.ss.usermodel.Workbook;
Import Org.apache.poi.ss.usermodel.Sheet;
Import Org.apache.poi.ss.usermodel.Row;
Import Org.apache.poi.ss.usermodel.Cell;
Workbook workbook = (workbook) modelutils.getrequestcontext (). Getactioncontext (). GetParameter ("Excel");
Sheet Sheet = workbook.getsheetat (0);
int FR = Sheet.getphysicalnumberofrows ()-4;
for (int i=0;i<fr;i++) {
int r = 4+i;
Org.apache.poi.ss.usermodel.Row Rowdetail = Sheet.getrow (R);
String guarantee_date = "";
Cell Datecell = Rowdetail.getcell (2);
Determine whether a date type
if (0==datecell.getcelltype ()) {
if (dateutil.iscelldateformatted (Datecell)) {
Used to convert to date format
Date d = datecell.getdatecellvalue ();
DateFormat formater = new SimpleDateFormat ("Yyyy-mm-dd");
Guarantee_date = Formater.format (d);
}
}
System.out.println (guarantee_date);
------------integer number format processing--------------
String countstr = Rowdetail.getcell (3). ToString ();
Integer count = 0;
System.out.println ("Warehousing Quantity:" +countstr);
if (Countstr.indexof (".") >=0) {
System.out.println (". Number of digits: "+ countstr.indexof (". "));
Countstr = countstr.substring (0, Countstr.indexof ("."));
Count = integer.valueof (COUNTSTR);
}
}