Im using soapui open source and it s not related to data driven test.
i just need to generate an excel file xlsx for my test.
That's what it is all about.
So here is a functionnal Groovy script:
import org.apache.poi.ss.usermodel.Cell
import org.apache.poi.ss.usermodel.Row
import org.apache.poi.xssf.usermodel.XSSFSheet
import org.apache.poi.xssf.usermodel.XSSFWorkbook
import java.io.FileOutputStream
import java.io.IOException
import java.util.List
XSSFWorkbook workbook = new XSSFWorkbook()
XSSFSheet sheet = workbook.createSheet("SheetName")
int rowNum = 0
int colNum = 0
headers = ["Col1", "Col2", "Col3"]
Row row = sheet.createRow(rowNum)
for(String header : headers) {
Cell cell = row.createCell(colNum++)
cell.setCellValue(header)
}
rowNum = 1
colNum = 0
row = sheet.createRow(rowNum++)
Cell cell = row.createCell(colNum++)
cell.setCellValue("First Value")
cell = row.createCell(colNum++)
cell.setCellValue("Second Value")
cell = row.createCell(colNum++)
cell.setCellValue("Third Value")
try {
FileOutputStream outputStream = new FileOutputStream("C:\\Users\\<userName>\\Documents\\ExcelFile.xlsx")
workbook.write(outputStream)
workbook.close()
} catch (IOException e) {
e.printStackTrace()
}
Please don't forget you will need apache poi jar files into your SoapUI bin/ext folder.
Made this script with 3.1 version.
Let me know if it's OK for you.
David.