I am Trying to Find the String in a particular column but as a result it is giving me all the cells from the sheet.
Here is My Code.
FindOptions findOptions = new FindOptions();
Cell prevCell = null;
for (int n1=0;n1<=num;n1++)
cell1 = cells.find(“Hello”,prevCell,findOptions);
System.out.println("Name of the cell containing formula: " + cell1.getName());
Style style = cells.getCell( n1,3).getStyle();
prevCell = cell1;
FindOptions.SEARCH_BY_COLUMNS will find string column by column. Means, it will first search for string in a particular column then move to next column and search there and then move to next column so on.
It will find all the strings though.
Is there any Other way to find it only in columns. with find options?
I think no. Please see the image below and the sample xlsx file for further illustration.
However, you can use this condition to restrict yourself to single column. Please see the pseudo code below.
int yourColumn=2; //suppose you are looking third column
while(nextCellFound.getColumnIndex() == yourColumn)
//Keep looking for next cells containing your search value