Forum Discussion
JKambli
Staff
Here is a sample script,
import java.io.File; import java.io.FileInputStream; import java.util.Iterator; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; FileInputStream file = new FileInputStream(new File('C:\\sample.xls')); XSSFWorkbook workbook1 = new XSSFWorkbook(file) XSSFSheet sheet1 = workbook1.getSheetAt(0) Iterator ite = sheet1.rowIterator(); headers=[] Row row = ite.next(); Iterator<Cell> cite = row.cellIterator(); while(cite.hasNext()){ Cell c = cite.next(); headers << c.toString() } file.close(); log.info headers for ( i in headers ) { testRunner.testCase.testSteps["DataSource"].addProperty(i); }
Related Content
- 3 years ago
- 10 years ago
- 6 years ago
Recent Discussions
- 6 days ago
- 10 days ago