How to use a regex in groovy for reading a excel file and assign a value.
hallo, I am trying to read an xls file having few columns and rows. I am getting a string value from an api and from this string value i am trying to look into the row having six values. There is an output value which i then compare and assign a closest value to it and choose which columnnamenumber. Let me explain with an example with the picture i have attached. In this case, i get a string value "test8" this excel makes a search and i have already implemented and i get the result for example "test8" with a output value 176. Now the row values which are in test8 are 174 181 192 204 211 My task is in reading this alle row cell values which is assigned to row "test8" If have a output value for a number 176 from the below code def output= bucket.getoutput(). Here maybe i need to use regex. i do not know! i wanted to use it for the previous row value in this case for 174 from six row values. Then it would search for which column header it is assigned, in this case it would be -1. If the output value was somewhere in around 191-204 ex(198). Then it should setcolumn name to +1. Please helpme in building/suggesting it. I have added my class file. I am not getting the right output i need. I have defined in the line def value. ps: Sheet1 code looks for the program from the data slotnumber which is already been implented. case1,case2 is minimumvalue and maximumvalue. I tried : private void calculateweight(BBucket bucket, ZWorkbookImpl workbook) { //find right row, extract data try { def testProgram = bucket.getTestProgram() workbook.goToSheet("Sheet2") workbook.goToPosition(0, 0) //Searches for particular test program in the first column ex:Test8 while(true) { if(workbook.readCell(false).contentEquals(testProgram)) // Here it finds Test8, now how to get the values of row Test8 ?? { workbook.goToNextCell() der value = //Todo "read the values of particular row and take one value which fits" container.getAll(new FilterAllDomainObjects()).each{e -> e.setProgramExtension(value) //calculate program //Store program on the stent } break; } workbook.goToNextRow(false) } } catch (Exception e) { throw new Exception("Error parsing ${fileName} file", e) } }Solved1.1KViews0likes3Comments