public boolean testInsertUser() { try { User user = new User(); user.setId(1); user.setName("wangchaobo"); user.setAddress("hunan"); user.setBirthday(new Date()); // user.setGender(1); simpleDao.createEntity(user); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; }
private int getUserFormXSheet(Sheet userSheet) { int count = 0; if (userSheet == null) return 0; try { int rowStart = userSheet.getFirstRowNum(); int rowEnd = userSheet.getLastRowNum(); for (int i = rowStart + 1; i <= rowEnd; i++) { Row row = userSheet.getRow(i); User user = new User(); String strid = String.valueOf(getXssCellData(row.getCell(0))); if ("".equals(strid)) continue; int id = Integer.parseInt(strid); String name = (String) getXssCellData(row.getCell(1)); String address = (String) getXssCellData(row.getCell(2)); String str_borthday = getXssCellData(row.getCell(3)).toString(); Date borthday = null; if (!"".equals(str_borthday)) { try { borthday = new SimpleDateFormat("yyyy-MM-dd").parse(str_borthday); } catch (Exception e) { } } String gender = (String) getXssCellData(row.getCell(4)); user.setId(id); user.setName(name); user.setAddress(address); user.setBirthday(borthday); if ("男".equals(gender)) { user.setGender("男"); } simpleDao.createEntity(user); count++; } } catch (Exception e) { e.printStackTrace(); log.error("getUserFormXSheet exception !"); } return count; }