Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
public static String splitColumnHandling(String Field)
{
String str = Field;
String ValueHolder="";
String[] myarray = str.split("; ");
String a="";
String b="";
try
{
//Create Workbook instance holding reference to .xlsx file
FileInputStream file = new FileInputStream(new File("D:\\MY PROJECT\\lookup_table.xlsx"));
XSSFWorkbook workbook = new XSSFWorkbook(file);
//Get first/desired sheet from the workbook
XSSFSheet sheet = workbook.getSheetAt(0);
//begin loop spliting
for(int i = 0; i < myarray.length; i++)
{
a=myarray.toString();
//Iterate through each rows one by one
Iterator<Row> rowIterator = sheet.iterator();
for(int x = 0; x < sheet.getPhysicalNumberOfRows(); x++)
{
//Declare cell position to be read
Row row = rowIterator.next();
CellReference pos_return_value = new CellReference("D1");
CellReference pos_lookup_codes = new CellReference("C1");
Cell get_return_value = row.getCell(pos_return_value.getCol());
Cell get_lookup_codes = row.getCell(pos_lookup_codes.getCol());
if(a.equals(get_lookup_codes.getStringCellValue()))
{
if(i!=(myarray.length-1)){
ValueHolder=ValueHolder+get_return_value+"; ";
}else{
ValueHolder=ValueHolder+get_return_value+"";
}
}
else if(a.equals("NONE SPECIFIED") )
{
ValueHolder="NONE SPECIFIED";
}
}
b=b+"\n"+a;
}
if (ValueHolder.isEmpty()){
ValueHolder=Field;
}
}catch(Exception e )
{}
return String.valueOf(ValueHolder);
}
}//end