TXlsFile find problem

Goodafternnon,

j have a strange problem with TXlsFile find procedure.



J'm using this procedure to try if, a typed word, is located in the .xls file.



Cell := Xls.Find(Edt10.Text, TXlsCellRange.Null, TCellAddress.Create(1,1), false, true, false, false);



where



Cell : TCellAddress;

Xls : TXlsFile;



The problem is that Edt10.Tex is locatd in all cells excpt in cells [1,1]



Where is my error ??



Thank's in advance for your interest



Best regard



Daniele

Hi,

Sorry, there is an error in the example, which has already been corrected internally, but not released yet.

Your line should be:
Cell := Xls.Find(Edt10.Text, TXlsCellRange.Null, TCellAddress.Empty, false, true, false, false); 

And the example in the docs should be:
    /// <code>
    /// Cell := TCellAddress.Empty;
    /// repeat
    ///   Cell := xls.Find('bolts', TXlsCellRange.Null, Cell, false, true, true, false);
    ///   if (Cell.HasValue) then ShowMessage(Cell.CellRef);
    /// until (Cell.IsNull);
    /// </code>
    /// </example>

Going a little more on detail on what happens here:
Find search from the next cell that you specify. So if you specify (1, 1) it will start searching in (2, 1) or (1, 2) depending if you are searching by rows or by columns.

This is because if not it would enter an infinite loop.

If the original cell is A1, and we searched including A1, then the line
the line Cell := xls.Find(…Cell…)

Would keep finding A1 forever. So we need to search from the next cell to A1, in order to give you the next result. But then, you need to start with null, not A1 the first time, or  A1 will never be searched.

Good morning,

thank's Adrian, the infinte loop is what j had !!!



Now is all ok (just for today)



Regards



Daniele