Free Support Forum - aspose.com

Problems with FindStringContains with cellArea

Hi,



I’ve notice that the FindStringContains doesn’t work properly when the CellArea overload is used (Cells.FindStringContains(String, Cell, Boolean, CellArea)).



for example:



public void FindStringContains()

{

var workbook = new Workbook();

workbook.Open(“C:\FindStringContains.xls”, FileFormatType.Default);



var grid = workbook.Worksheets[0];



Cell foundCell = null;

foundCell = grid.Cells.FindStringContains(“Test”, foundCell, false);



// THIS ASSERTION WORKS

Debug.Assert(foundCell != null, “Failed to find without cellArea.”);



var cellArea = new CellArea

{

StartRow = 0,

EndRow = 1,

StartColumn = 0,

EndColumn = 1

};



foundCell = grid.Cells.FindStringContains(“Test”, foundCell, false, cellArea);



// THIS ASSERTION FAILS

Debug.Assert(foundCell != null, “Failed to find with cellArea.”);

}



Attached is the spreadsheet that I used for this test, which contains a cells with the value “Test” in cell A1.



-Steve

Hi Steve,

Thanks for reporting,

Yes, we found the issue with the overloaded version i.e., Cells.FindStringContains(inputString, prevCell, isCaseSensitive, cellArea), we will fix it soon.

Thank you.

Hi Steve,

Please try this fix and change the codes as the following:

public void FindStringContains()
{
var workbook = new Workbook();
workbook.Open("C:\FindStringContains.xls", FileFormatType.Default);

var grid = workbook.Worksheets[0];

Cell foundCell = null;
foundCell = grid.Cells.FindStringContains("Test", foundCell, false);

// THIS ASSERTION WORKS
Debug.Assert(foundCell != null, "Failed to find without cellArea.");

var cellArea = new CellArea
{
StartRow = 0,
EndRow = 1,
StartColumn = 0,
EndColumn = 1
};
foundCell = null;

foundCell = grid.Cells.FindStringContains("Test", foundCell, false, cellArea);

// THIS ASSERTION FAILS
Debug.Assert(foundCell != null, "Failed to find with cellArea.");
}