jeecg excel 导入到java

来源:互联网 发布:最新博客网站程序源码 编辑:程序博客网 时间:2024/06/05 11:31

TSAttachment tsAttachment = systemService.getEntity(TSAttachment.class,ttachementId);  //获得excel.

List<CcReportFormEntity> list = reportFormService.getPartsList(tsAttachment);//获取表中数据    调用serice


public List<CcReportFormEntity> getPartsList(TSAttachment tsAttachment) {
try {
String realpath = ResourceUtil.getConfigByName("realpath");
String downpath = realpath + tsAttachment.getRealpath();// 拼接全路径
List<CcReportFormEntity> list = new ArrayList<CcReportFormEntity>();
FileInputStream fis = new FileInputStream(downpath);
Workbook wb = new HSSFWorkbook(fis);
Sheet sht = wb.getSheetAt(0);
for (Row r : sht) {
if (r.getRowNum() < 1) {
continue;
}
CcReportFormEntity reportFormEntity = new CcReportFormEntity();
reportFormEntity.setModelNumber(r.getCell(0).getStringCellValue());   取得每一排的第一列


list.add(reportFormEntity);
}
fis.close();
return list;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}



原创粉丝点击