這是讀取Excel的代碼
InputStream is = null;
String name = null;
String sex = null;
String phone = null;
try {
is = getAssets().open("test.xlsx");
Workbook workbook = WorkbookFactory.create(is);
Sheet sheet = workbook.getSheetAt(0);
int rowCount = sheet.getPhysicalNumberOfRows();
for (int r = 0; r < rowCount; r++) {
Row row = sheet.getRow(r);
int cellCount = row.getPhysicalNumberOfCells(); // 獲取總列數
for (int c = 0; c < cellCount; c++) {
Cell cell = row.getCell(c);
int cellType = cell.getCellType();
String cellValue = null;
switch (cellType) {
case Cell.CELL_TYPE_STRING: // 文本
cellValue = cell.getStringCellValue();
if (cellValue.equals("男")||cellValue.equals("女")) {
sex=cellValue;
}
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.put("name", name);
values.put("sex", sex);
values.put("phone", phone);
service.addPerson(values);
}
} catch (Exception e) {
e.printStackTrace();
}
這是匯入的jar包



困擾很久了 ,跪求 大神指點!!
uj5u.com熱心網友回復:
表示沒接觸過,幫頂下吧!uj5u.com熱心網友回復:
【NoClassDefFoundError:Failed resolution of 】錯誤型別已經指出是決議失敗。升級下jdk或jar包試試。轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/133443.html
標籤:Android
上一篇:盜號
