Hi team,
In a sheet, i need to find the count of a word for example, i need to find how many times the word “Description” is there in a worksheet?
like we do in word doc,
int iReplace = doc.getRange().replace(sWord, sWord, new FindReplaceOptions());
iReplace will return the count of words in Document.
same like i am looking in excel .
Thanks,
Naveena
@nawinaajj,
You need to use some loop to find each string and get its count accordingly. See the sample code for your reference:
e.g
Sample code:
String strFind = "Description";
int cnt = 0;
Workbook workbook = new Workbook(filePath);
Worksheet worksheet = workbook.getWorksheets().get(0);
FindOptions opts = new FindOptions();
opts.setLookInType(LookInType.VALUES);
Cell cell = null;
do
{
cell = worksheet.getCells().find(strFind, cell, opts);
if(cell!=null)
{
cnt++;
}
}
while(cell!=null);
}
if(cnt > 0)
System.out.println("Count="+cnt);
Hope, this helps a bit.