| 6 | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| 7 | |
| 8 | public class DataLibrary { |
| 9 | public static Object[][] readExcelData(String excelfileName) { |
| 10 | XSSFWorkbook wbook; |
| 11 | Object[][] data = null ; |
| 12 | try { |
| 13 | wbook = new XSSFWorkbook("./data/"+excelfileName+".xlsx"); |
| 14 | XSSFSheet sheet = wbook.getSheetAt(0); |
| 15 | int rowCount = sheet.getLastRowNum(); |
| 16 | int colCount = sheet.getRow(0).getLastCellNum(); |
| 17 | data = new Object[rowCount][colCount]; |
| 18 | for (int i = 1; i <= rowCount; i++) { |
| 19 | for (int j = 0; j < colCount; j++) { |
| 20 | data[i-1][j] = sheet.getRow(i).getCell(j).getStringCellValue(); |
| 21 | } |
| 22 | } |
| 23 | wbook.close(); |
| 24 | } catch (IOException e) { |
| 25 | System.err.println(e.getMessage()); |
| 26 | } |
| 27 | return data; |
| 28 | } |
| 29 | } |
nothing calls this directly
no outgoing calls
no test coverage detected