0
FileInputStream input=new FileInputStream(new File("TestCase.xls"));
HSSFWorkbook workbook=new HSSFWorkbook(input);
HSSFSheet sheet=workbook.getSheet("KeywordFramework");
System.out.println("i am in"); 
int rowNum = sheet.getLastRowNum() + 1;
System.out.println(rowNum);
int colNum = sheet.getRow(0).getLastCellNum();
System.out.println(colNum);
String data [][] = new String[rowNum][colNum];
for(int i =1 ; i< rowNum;i++)       
{
    System.out.println("1");
    HSSFRow row = sheet.getRow(i);
    for(int j = 0; j< colNum;j++)           
    {
    System.out.println("2");
    HSSFCell cell = row.getCell(j);
    String Cellvalue = cellToString(cell);
    System.out.println("cellvalue === "+Cellvalue);
    switch(j)
    {
        case 0 : Function ; break;
        case 1 : Function ; break;
        case n : Function(has 2 nested for loops) ; break;
    } // for switch
    Function;
} // for j loop } // for i loop

Null pointer exception Found , i have called one of a cell in case n and braked out but still the same value is called again from the excel and is trying to place that cell value in my code and is not able to do so as there is no more cases , i dont want my code to call the excel cell again in the same row , it should jump out of loop and execute the next row which is not happening

Thank you

4
  • 5
    What exactly are you trying to do? Commented Jul 7, 2014 at 6:36
  • 1
    You cannot add 1 to an object of type Dimension. Why are you complicating your life? Use int i. Commented Jul 7, 2014 at 6:38
  • Do you want loop over the width, or over the height of the Dimension? Because Dimension has both. Commented Jul 7, 2014 at 6:41
  • I want to use both hieght and width values Commented Jul 7, 2014 at 7:03

1 Answer 1

0

Your question isn't clear, if you want to loop over the height of the element that would be

for(int a=0;a<SOT.getHeight();a++)

or for the width,

for(int a=0;a<SOT.getWidth();a++)

From the Javadoc for Dimension

The Dimension class encapsulates the width and height of a component (in integer precision) in a single object.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.