Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ExcelRead {
- public static void main(String[] args) throws Exception {
- File excel = new File ("C:/Users/user/Desktop/Files/Dashboards.xlsx");
- FileInputStream fis = new FileInputStream(excel);
- XSSFWorkbook wb = new XSSFWorkbook(fis);
- XSSFSheet sheet = wb.getSheetAt(0);
- int rowNum = sheet.getLastRowNum()+1;
- int colNum = sheet.getRow(0).getLastCellNum();
- String[][] data = new String[rowNum][colNum];
- for (int i=0; i<rowNum; i++){
- //get the row
- XSSFRow row = sheet.getRow(i);
- for (int j=0; j<colNum; j++){
- //this gets the cell and sets it as blank if it's empty.
- XSSFCell cell = row.getCell(j, Row.CREATE_NULL_AS_BLANK);
- String value = String.valueOf(cell);
- System.out.println("Value: " + value);
- }
- }
- System.out.println("End Value: " + data[2][2]);
- }
- }
- Value: Project Name
- Value: Dashboard URL
- Value: To Email
- Value: From Email
- Value: Jira Login
- Value: Password (same for )
- Value: Image Location
- Value: Run Automation
- Value: Project1
- Value: ProjectURL
- Value: testemail@email.com
- Value: QAAutomation@email.com
- Value: QAAutomation
- Value: QARocks#2
- Value: test
- Value: yes
- Value: Project2
- Value: https://projectURL
- Value: testemail@email.com
- Value: QAAutomation@email.com
- Value: QAAutomation
- Value: QARocks#2
- Value: test
- Value: yes
- End Value: null
- array[i][j] = value;
- data[i][j]
- for (int i=0; i<rowNum; i++){
- //get the row
- XSSFRow row = sheet.getRow(i);
- for (int j=0; j<colNum; j++){
- //this gets the cell and sets it as blank if it's empty.
- XSSFCell cell = row.getCell(j, Row.CREATE_NULL_AS_BLANK);
- String value = String.valueOf(cell);
- data[i][j] = value;
- System.out.println("Value: " + value);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement