for ( int i = 0; i < s.getColumns(); i++ )
{
if (s.getCell(i,0).getContents() == "Type" );
{
typeIndex = i;
System.out.println(s.getCell(i,0).getContents());
}
}
Basically I have an excel file, and a sheet declared as s
I am using a for
loop to iterate through all the columns of the sheet.
I am looking for the heading called "Type" by searching each column heading using row 0, and then I want to store the column index wherever the column with "Type" heading is found, in the variable typeIndex
When I try to do this, it always reads the if statement as true.
code explanation:
The if statement basically gets the column heading at the current ith iteration, and compares it to the string "Type". I am also printing the column heading each time, and they are not all "Type" , they are correctly iterating and showing the different column names in the excel sheet.
But it shouldn't even be entering the if statement then..? Please comment if you need further elaborating, tried to explain it the best I could.