Contributions
Read excel data and extract value in groovy
Hi, Need help on how I can read excel file and extract value with specific text like "am" and merge it with other values using groovy code. Sample input in excel: Firstname Lastname Amalia Miranda Jayson Kind Henry Gomez Miriam Ostola Expected Output: Amalia Miranda Miriam Ostola Right now here's my code for checking character 'am'. my ouput only returns am but expected is to print Amalia Miranda and Miriam Ostola import java.util.regex.Matcher; import java.util.regex.Pattern; final String regex = "am"; final String string = "amalia"; final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE); final Matcher matcher = pattern.matcher(string); while (matcher.find()) { System.out.println("Full match: " + matcher.group(0)); for (int i = 1; i < matcher.groupCount(); i++) { System.out.println("Group " + i + ": " + matcher.group(i)); } } And my code for reading excel but still encountering error: import org.apache.poi.ss.usermodel.* import org.apache.poi.ss.usermodel.Sheet import org.apache.poi.ss.usermodel.Workbook import org.apache.poi.xssf.usermodel.XSSFWorkbook def ReadCellData(int vRow, int vColumn) { try { fis = new FileInputStream("GROOVY\\name.xlsx"); wb = new XSSFWorkbook(fis); print FileInputStream(); } catch(FileNotFoundException e) { e.printStackTrace(); } catch(IOException e1) { e1.printStackTrace(); } sheet = wb.getSheetAt(0); row = sheet.getRow(vRow); cell = row.getCell(vColumn); return cell.getStringCellValue(); } vOutput=ReadCellData(0, 0); println(vOutput); Would be happy if this 2 code ideas will be merge. I am new to groovy coding. Thanks.5.1KViews0likes2Comments