从excel文件里读取数据,遇到姓名相同的数据跳过,请问怎么做效率最高?
如:
for(int i=0; i< maxnum; i++) {  //.........................
}maxnum是excel文件的记录条数

解决方案 »

  1.   

    不管用什么,始终要作判断塞
    我目前的做法是:
    for(int i=0; i< maxnum; i++) {
        HSSFRow row = sheet.getRow(i);
        HSSFCell userIds = row.getCell((short) 0);
        String userId = valueToString(userIds);    //姓名(excel表的第1行第1列值)
        .......................
        List temp = new ArrayList(); 
        if(temp.indexOf(userId) >= 0) {
            continue;
        } else{
            //user.setUserId(userId);
            //..........
            //Factory.getUserFactory.createuser(user);  
            temp.add(userId);
        }  
    }
      

  2.   

    用hashmap,用name作为key,它自己会判断是否有重复的