i want to delete duplicates data in my excel row. so if there is a duplicate data, the system automatic break the loop and clear entire data in the cycle loop
I want to remove all of these duplicates in row Dept Code and just want unique records here. My piece of code is
//sheet 4
rowIterator_4 = sheet_4.iterator();
//loop sheet 4
while (rowIterator_4.hasNext()) {
row_4 = null;
row_4 = rowIterator_4.next();
if (row_4 == null) {
break;
}
// skip the header
if (rowNo_4 > 1) {
String level = getCellValue(row_4.getCell(0));
String deptCode = getCellValue(row_4.getCell(1));
String deptName = getCellValue(row_4.getCell(2));
// if all cells within a row are empty, stop process
if (
(level == null || level.trim().length() == 0) &&
(deptCode == null || deptCode.trim().length() == 0) &&
(deptName == null || deptName.trim().length() == 0)
) {
// exit
break;
}
if (level == null || level.length() == 0) {
error += "Level is empty on line " + rowNo_4 + "<br/>";
}
if (deptCode == null || deptCode.length() == 0) {
error += "Dept Code is empty on line " + rowNo_4 + "<br/>";
}
if (deptName == null || deptName.length() == 0) {
error += "Dept Name is empty on line " + rowNo_4 + "<br/>";
}
os = null;
os = new ImportExcelToDB();
os.setLevel(level);
os.setDeptCode(deptCode);
os.setDeptName(deptName);
if (list3.equals(deptCode)) {
error += "Dept Code is duplicate on line " + rowNo_4 + "<br/>";
break;
}
if (os != null) {
list3.add(os);
}
}
rowNo_4++;
}
Thank you guys