本文主要是介绍jeecg excel 导入到java,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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;
}
这篇关于jeecg excel 导入到java的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!