使用POI读取Excel报异常java.lang.ClassNotFoundException

g94597437 2016-04-01 08:36:57
这是读取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= 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包





困扰很久了 ,跪求 大神指点!!
...全文
3413 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复

myexcel中引入了poi,看下是不是版本冲突了

百味岩 2019-06-25
  • 打赏
  • 举报
回复
【NoClassDefFoundError:Failed resolution of 】错误类型已经指出是解析失败。升级下jdk或jar包试试。
ganshenml 2016-04-01
  • 打赏
  • 举报
回复
表示没接触过,帮顶下吧!

80,472

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧