.FindString is obsolete

SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
Workbook wbook = new Workbook(templatePathFinal);
Worksheet sheet = wbook.Worksheets[0];
Cells cells = sheet.Cells;
Aspose.Cells.Cell dateCol = cells.FindString("Date", null); //warning is here

if (!(dateCol == null))
{
... other code ...
sheet.Cells.ApplyColumnStyle(dateCol.Column, style, flag);
}

I'm getting a warning on the above mentioned line saying .FindString is obsolete. Can you please help me update it to current standards. I searched and couldn't find exact way to fix this. Your help is appreciated.

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Yes, you are right, it is now obsolete. Now you will use Find() method with FindOptions parameter to search your desired string.

For your complete help, we will recommend you to please study this article and its code and then you can modify it as per your needs.

Thanks.

I ended up replacing it with the following:

SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
Workbook wbook = new Workbook(templatePathFinal);
Worksheet sheet = wbook.Worksheets[0];
Cells cells = sheet.Cells;
ArrayList linkList = new ArrayList();

//Instantiate FindOptions Object
FindOptions findOptions = new FindOptions();

//Create a Cells Area
CellArea ca = new CellArea();
ca.StartRow = 0;
ca.EndRow = 0;

//Set cells area for find options
findOptions.SetRange(ca);

//Set searching properties
findOptions.SearchNext = true;
findOptions.SeachOrderByRows = true;

//Set the lookintype, you may specify, values, formulas, comments etc.
findOptions.LookInType = LookInType.Values;

//Set the lookattype, you may specify Match entire content, endswith, starwith etc.
findOptions.LookAtType = LookAtType.EntireContent;
//findOptions.LookAtType = LookAtType.Contains; //may use later if more dates come into play

//Find the cell with "Date" value
Aspose.Cells.Cell dateCol = cells.Find("Date", null, findOptions);

Aspose.Cells.Style style = null;
StyleFlag flag = new StyleFlag();

if (!(dateCol == null))
{
...
sheet.Cells.ApplyColumnStyle(dateCol.Column, style, flag);
}v

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

That’s great, you were able to successfully upgrade your obsolete code and you shared a solution with others too. Hopefully, this post will be helpful for others too.

We also wish you a great 2013 year. :slight_smile:

Besides that, I will also recommend you to check the find-or-search-data demo from the Aspose.Cells for .NET demos.

These demos will help you to get familiar with Aspose.Cells API(s) quickly and you will be able to know and use the new/existing features of Aspose.Cells easily.

These demos can work with Visual Studio 2005, 2008 or 2010. Please read the readme.txt file before running the demos.