Hello,
I have the following code block in an application that worked successfully using Aspose.Cells version 20.3.0.0, but after upgrading today to the latest 21.5.0.0 version of Aspose.Cells it has stopped working. Within the do…while loop, the value of foundCell is always null when I know that there are empty cells.
To build the spreadsheet, I am using Workbook workbook = new Workbook(); and then using worksheet.Cells.ImportData(dv.ToTable(), 0, 0, importOptions); to populate the cells. Just after populating the cells, I am running the following code.
commonNameIndex = worksheet.Cells.Columns[worksheet.Cells.Find("CommonName", null, new FindOptions() { LookAtType = LookAtType.EntireContent }).Column].Index;
//Sort by CommonName A-Z
worksheet.AutoFilter.Sorter.Clear();
worksheet.AutoFilter.Sorter.Key1 = commonNameIndex;
worksheet.AutoFilter.Sorter.Order1 = Aspose.Cells.SortOrder.Ascending;
worksheet.AutoFilter.Sorter.Sort();
//Apply VLOOKUP for blank Common Names
Cell prevcell = null;
Cell foundCell = null;
string stringToFind = string.Empty;
FindOptions opts = new FindOptions();
//Create a Cells Area based on the Common Name column (column E) only
CellArea ca = new CellArea
{
StartRow = 0,
StartColumn = commonNameIndex,
EndRow = worksheet.Cells.MaxDataRow,
EndColumn = commonNameIndex
};
//Set cells area for find options
opts.SetRange(ca);
opts.LookAtType = LookAtType.EntireContent;
opts.LookInType = LookInType.Formulas;
columnLookup = worksheet.Cells.Columns[worksheet.Cells.Find("ShortPolicyNumber", null, new FindOptions() { LookAtType = LookAtType.EntireContent }).Column];
do
{
foundCell = worksheet.Cells.Find(stringToFind, prevcell, opts);
if (foundCell == null)
break;
if (foundCell.StringValue == "")
{
foundCell.R1C1Formula = "=VLOOKUP(RC[16],'Common Name'!C[-3]:C[-1],3,FALSE)";
}
prevcell = foundCell;
} while (foundCell != null);
Can you spot anything that I am doing wrong?
Thank you!