Outbounde Exception the second time that I try to read an Excel with SoapUI
I'm trying to read the datas of an excel with the objects
wb = Workbook.getWorkbook(new File('C:/Users/Franciscog/Desktop/papageno1.xls'))
It works fine the first time that I use, but the second time, I get this message:
java.lang.ArrayIndexOutOfBound.Exception:0error at line: 12
I have to add new rows and columns to the excel in order to make it works again. Any idea of why is it?
Thanks a lot in advance
Really, I would not need anything of xml, it is just the code that I found for reading datas from an Excel. Now I got this new one that is better.
I need this because I should send messages of vehicles that has some of their fields with just some allowed values, for example, odometer unit: Milles, Hours or Kilometres. Then, I would like to put all those values in an excel and take them for each message (I should send the same number of messages as possible values).
Thanks you and best regards.
There is simple way to achieve the same differently.
Create a .csv file for valid values for odometer as shown below:
odometer.csv - contents of the file
For more details about xlson library, visit github
Here is the script which reads the above csv file and selects one of values randomly
import static com.xlson.groovycsv.CsvParser.parseCsv //Provide the file path of odometer csv def data = parseCsv(new File('/tmp/odometer.csv').text) def odometerUnits = data*.values.flatten() //Randomly selects def selectedValue = odometerUnits[new Random().nextInt(odometerUnits.size())] log.info "Current selection: $selectedValue"