Can FindString() return an arrary of Cells?

Hi ,

I've use FindString() to find a word in the worksheet. My problem is that the word occurs more than once in the worksheet. FindString() only return a single cell, is it possible to return an array of cells if there is more than 1 occurences?

Thanks,

Dawn

Hi,

Thanks for considering Aspose.

you may use your own code to find all the occurences of your data. May the following code helps you for your need:

Workbook workbook =new Workbook();
workbook.Open("d:\\test\\MyBook.xls");
Worksheets worksheets = workbook.Worksheets;

try
{
Worksheet worksheet = workbook.Worksheets[0];
Cells cells = worksheet.Cells;
ArrayList al = new ArrayList();
Cell foundcell;
Cell prevcell = null;
int i = 0;
string datatosearch = "DATA";



do
{

foundcell = cells.FindString(datatosearch,prevcell);
//when no data found exit the loop.
if (foundcell == null)
break;
al.Add((string)foundcell.Name);
prevcell = foundcell;

}while(foundcell!= null);

//Convert the arraylist to string array,
//the array contains cell names.
string []scells =(string[]) al.ToArray(typeof(string));
MessageBox.Show("Total Cells found : " + scells.Length);

//Scan the array to fetch the cell names.
for (int a=0;a<scells.Length;a++)
{
MessageBox.Show(scells[a]);

}

}
catch (Exception ee)
{
MessageBox.Show(ee.Message);

}
Thank you.