We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

FindString vs Find

I am trying to replace the depricated FindString() method with the Find() method. My results are inconsistent using the new method.

What FindOptions properties should be set to mimic exactly how FindString() functioned?

// OLD CALL

Aspose.Cells.Cell chCell = cells.FindString(placeHolderName, prevCell);
//NEW CALL
Aspose.Cells.Cell chCell = cells.Find(placeHolderName, prevCell, new FindOptions());

Hi,


Well, you should properly set the FindOptions accordingly.
e.g
Sample code:

FindOptions findOptions = new FindOptions();
findOptions.CaseSensitive = false;
findOptions.LookInType = LookInType.Values;
findOptions.LookAtType = LookAtType.Contains

Aspose.Cells.Cell chCell = cells.Find(placeHolderName, prevCell, findOptions);

Thank you.

Can you please confirm if findOptions.LookInType was LookInType.Values; or ValuesExcludeFormulaCell in “FindString()”. The reason I am asking is that “FindString()” does not find the string which is derived as a Formula output but LookInType.Values find the string which is a formula output. Can you please confirm?

FindOptions findOptions = new FindOptions();

findOptions.CaseSensitive = false;

findOptions.LookInType = LookInType.Values;

findOptions.LookAtType = LookAtType.Contains

Aspose.Cells.Cell chCell = cells.Find(placeHolderName, prevCell, findOptions);

@santhoshsas,
Could you please share your sample Excel file, runnable console application and expected output? We will reproduce the scenario here and provide assistance accordingly.

Hi,

Please find the attached sheet which has "###Test in Sheet1 A1. Sheet 2 A2 has “=Sheet1A1” and this formula returns “###Test” from Sheet1.

When I do using Apose v17.6
Cell cell2 = workbook.Worksheets[1].Cells.Find("###Test", cell, findOptions);

cell2 value is null

But with Aspose v19.6 , using cells.Find --> Cells 2 is “###Test

FindOptions findOptions = new FindOptions();
findOptions.CaseSensitive = false;
findOptions.LookInType = LookInType.Values;
findOptions.LookAtType = LookAtType.EntireContent;
Cell cell = null;

        Cell cell2 = workbook.Worksheets[1].Cells.Find("###Test", cell, findOptions);

But with findOptions.LookInType = LookInType.ValuesExcludeFormulaCell;

Cells2 is null and behaves the same way as Cells.FindString.

Can you let me know if LookInType in Cells.FindString is LookInType.ValuesExcludeFormulaCell; ?

Book1.zip (6.9 KB)

PFA the file.

@santhoshsas,
We have logged the issue in our database for investigations. Once, we will have some detailed information, we will update you in this topic. It has been logged as CELLSNET-47123.

Please let me know if there is any updates on CELLSNET-47123.

@santhoshsas,
Thank you for contacting Aspose support team again. This issue is still pending and no ETA is available yet. We will write back here as soon as some ETA is ready to share.

Thanks, we are looking forward for the answer at the earliest. Please do the needful.

@santhoshsas,
Sure, we will provide feedback at the earliest.

@santhoshsas,

Your understanding is right. Yes, the FindString method uses logic same with LookInType.ValuesExcludeFormulaCell.

Thanks for confirming.

@santhoshsas

You are welcome.