Advertisement
Guest User

Untitled

a guest
Aug 27th, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. public class ExcelRead {
  2.  
  3. public static void main(String[] args) throws Exception {
  4. File excel = new File ("C:/Users/user/Desktop/Files/Dashboards.xlsx");
  5. FileInputStream fis = new FileInputStream(excel);
  6.  
  7. XSSFWorkbook wb = new XSSFWorkbook(fis);
  8. XSSFSheet sheet = wb.getSheetAt(0);
  9.  
  10. int rowNum = sheet.getLastRowNum()+1;
  11. int colNum = sheet.getRow(0).getLastCellNum();
  12. String[][] data = new String[rowNum][colNum];
  13. for (int i=0; i<rowNum; i++){
  14. //get the row
  15. XSSFRow row = sheet.getRow(i);
  16. for (int j=0; j<colNum; j++){
  17. //this gets the cell and sets it as blank if it's empty.
  18. XSSFCell cell = row.getCell(j, Row.CREATE_NULL_AS_BLANK);
  19. String value = String.valueOf(cell);
  20. System.out.println("Value: " + value);
  21.  
  22. }
  23. }
  24. System.out.println("End Value: " + data[2][2]);
  25. }
  26. }
  27.  
  28. Value: Project Name
  29. Value: Dashboard URL
  30. Value: To Email
  31. Value: From Email
  32. Value: Jira Login
  33. Value: Password (same for )
  34. Value: Image Location
  35. Value: Run Automation
  36. Value: Project1
  37. Value: ProjectURL
  38. Value: testemail@email.com
  39. Value: QAAutomation@email.com
  40. Value: QAAutomation
  41. Value: QARocks#2
  42. Value: test
  43. Value: yes
  44. Value: Project2
  45. Value: https://projectURL
  46. Value: testemail@email.com
  47. Value: QAAutomation@email.com
  48. Value: QAAutomation
  49. Value: QARocks#2
  50. Value: test
  51. Value: yes
  52.  
  53. End Value: null
  54.  
  55. array[i][j] = value;
  56.  
  57. data[i][j]
  58.  
  59. for (int i=0; i<rowNum; i++){
  60. //get the row
  61. XSSFRow row = sheet.getRow(i);
  62. for (int j=0; j<colNum; j++){
  63. //this gets the cell and sets it as blank if it's empty.
  64. XSSFCell cell = row.getCell(j, Row.CREATE_NULL_AS_BLANK);
  65. String value = String.valueOf(cell);
  66. data[i][j] = value;
  67. System.out.println("Value: " + value);
  68.  
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement