Excel导入数据自己定义的
来源:互联网 发布:淘宝95小嫩模全集 编辑:程序博客网 时间:2024/05/16 15:46
// TODO 批量导入数据public String batchImport() throws Exception {SessionInfo sessionInfo = (SessionInfo) ServletActionContext.getRequest().getSession().getAttribute("sessionInfo");sysDepartList = new LinkedList<SysDepartEntity>();Properties config = getImportConfig();ExcelImporter importer = new ExcelImporter(config);try {String excelPath = this.excelFile.getAbsolutePath();importer.open(excelPath);while (importer.hasMore()) {Map<String, String> record = importer.get();// System.out.println(record); /转换为什么实体 SysDepartEntity sde = new SysDepartEntity();sde = EntityUtil.buildEntity(record, SysDepartEntity.class); 也可以自己转换 // sde.setDepartName(record.get("departName"));sde.setDepartParent(parentId);sde.setCreateBy(sessionInfo.getUserId());sde.setCreateDate(new Date());// 验证编码if (sysDepartImplBiz.validateDepartCode(sde.getId(), parentId, sde.getDepartCode())&& sysDepartImplBiz.validateDepartCode(sde.getId(), parentId, sde.getDepartCode())) {sysDepartImplBiz.saveSysDepart(sde);countR++;} else {sysDepartList.add(sde);countE++;}}} catch (Exception e) {throw e;} finally {if (importer != null) {importer.close();}}// sysDepartEntity.setDepartParent(parentId);// sysDepartList = sysDepartImplBiz.querySysDepartList(sysDepartEntity,// pageResult);flg = 1;return LIST;}Properties getImportConfig() {Properties config = new Properties();// sheet.name : sheet1// sheet.num : 0// config.setProperty("sheet.name", "sheet1"); //读取的是第个sheet表 config.setProperty("sheet.num", "0");// # start row or column number // row.begin : 2 // col.begin : 0 //第几行开始 config.setProperty("row.begin", "2"); //第几列 config.setProperty("col.begin", "0"); //每一列所填的字段是是什么config.setProperty("import.departName", "0");config.setProperty("import.departCode", "1");config.setProperty("import.fullName", "2");config.setProperty("import.telephone", "3");config.setProperty("import.fax", "4");config.setProperty("import.address", "5");config.setProperty("import.zip", "6");return config;}
0 0
- Excel导入数据自己定义的
- 自己用到的excel导入
- 导入excel格式的数据
- asp.net 将数据导入到excel中 出现 “object”未包含“get_Range”的定义
- C#将数据导入到excel中 出现 “object”未包含“get_Range”的定义报错
- C#将数据导入到excel中 出现 “object”未包含“get_Range”的定义
- 自己写的excel导入sqlserver函数
- 自己写的excel导入sqlserver函数
- 自己写的excel导入sqlserver函数
- 以后自己用的Excel批量导入
- 自己排序Excel的数据
- 导入EXCEL数据与自助式定义校验关系
- 定义自己的网络收发数据函数
- 将DataGrid的数据直接导入Excel
- excel数据导入mysql数据库的数据表
- VC导入数据到Excel的程序
- datalist的数据导入到Excel中
- excel数据导入mysql数据库的数据表
- java.sql.SQLException: Io exception: Connection reset
- VSFTPD全攻略(/etc/vsftpd/vsftpd.conf文件详解)
- UIView之endEditing方法
- 《失控》:最干货编录与总结
- Android NDK开发之 arm_neon.h文件ABI说明
- Excel导入数据自己定义的
- response压缩响应
- (Linux)TCP连接过程状态详解
- Android Http编程之HttpClient
- yuicompressor 与 maven结合,打包,压缩js,css
- 其无前例的springmvc+mybatis后台漂亮框架源代码
- 服务框架 Dubbo
- Method类的Invoke方法
- MSER特征