Forum Discussion

d82ej9dut's avatar
Occasional Contributor
7 years ago

Outbounde Exception the second time that I try to read an Excel with SoapUI

Hello everybody.   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 t...
  • d82ej9dut's avatar
    7 years ago

    Hello again.


    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.



  • nmrao's avatar
    7 years ago



    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




    Download xlson library and its dependency  

    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())] "Current selection: $selectedValue"