Jump to content

RyanLincoln

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by RyanLincoln

  1. On 6/17/2017 at 10:57 PM, newcoder1010 said:

    Hello, 

    Hello,

    I am a beginner of java. I wrote this code. When I run it in eclipse, I get an error: java lang null point exception. It does not tell me which line I have wrong code. Please advise on how to fix it. 
     

    
    	    	// Open the Excel file
    	    	FileInputStream fis = new FileInputStream(file);
    
    	    	// Access the required test data sheet
    	    	HSSFWorkbook wb = new HSSFWorkbook(fis);
    	    	HSSFSheet sheet = wb.getSheet("Sheet1");
                int  TotalCol;
                int  TotalRow;
    
               // TotalCol = 0;
                TotalRow = sheet.getLastRowNum();
                TotalCol = sheet.getRow(0).getLastCellNum();
       	        System.out.println("row " + TotalRow +  " col " +  TotalCol);
    
    			int resultcol;
    			resultcol = 0;
    	    	for(int col = 0;col<=TotalCol;col++){
    
    	    	     HSSFRow row1 = sheet.getRow(0);
    	    	     System.out.println("column names " + row1.getCell(col).toString() );
    	    	 	if("result".equalsIgnoreCase(row1.getCell(col).toString().trim()))
    				{
    	    	 		resultcol = col;
    		    	     System.out.println("result column number " + resultcol );
    
    				}
    	    		
    	    	}

     

    Have you tried to debug your code?

×
×
  • Create New...