Home > Mobile >  Use POI reading Excel at abnormal Java. Lang. ClassNotFoundException
Use POI reading Excel at abnormal Java. Lang. ClassNotFoundException

Time:10-22

This is the code reading Excel
 
InputStream is=null;
String name=null;
String sex=null;
String phone=null;


Try {
Is=getAssets (). The open (" test. XLSX ");
Workbook Workbook=WorkbookFactory. Create (is);
Sheet Sheet=workbook. GetSheetAt (0);
Int the rowCount=sheet. GetPhysicalNumberOfRows ();
For (int r=0; R & lt; RowCount; R++) {
The Row Row=sheet. GetRow (r);
Int cellCount=row. GetPhysicalNumberOfCells ();//get the total number of columns
For (int c=0; C & lt; CellCount; C + +) {
The Cell Cell=row. GetCell (c);
Int cellType=cell. GetCellType ();
String cellValue=https://bbs.csdn.net/topics/null;
The switch (cellType) {
Case Cell. CELL_TYPE_STRING://text
CellValue=(https://bbs.csdn.net/topics/cell.getStringCellValue);
If (cellValue. Equals (" male ") | | cellValue. Equals (" female ")) {
Sex=cellValue;
}
The else {
Name=cellValue;
}
break;
Case Cell. CELL_TYPE_NUMERIC:
DecimalFormat df=new DecimalFormat (" 0 ");
CellValue=https://bbs.csdn.net/topics/df.format (cell getNumericCellValue ());
Phone=cellValue;
break;
Default:
}
}
Values. The put (" name ", name);
Values. The put (" sex ", sex);
Values. The put (" phone ", phone);
Service. AddPerson (values);
}
} the catch (Exception e) {
e.printStackTrace();
}

This is to import the jar package





Trouble for a long time, a great god give directions! Genuflect is begged!

CodePudding user response:

Said didn't contact, help under the roof!

CodePudding user response:

[NoClassDefFoundError: Failed resolution of] wrong type have pointed to parse failure, upgrade the JDK or jar package a try,
  • Related