Enumerates the loaded cells in a classic XLS worksheet e calls an application callback for each cell
Sintassi
type
TXLSCellReadEvent = procedure(
Sender: TObject;
SheetIndex, Row, Col: Integer;
const Value: Variant;
const Formula: WideString;
var Cancel: Boolean) of object;
function ForEachCell(Callback: TXLSCellReadEvent): Integer;
Osservazioni
ForEachCell walks only cells that exist in the loaded worksheet model. It does not scan every possible row e column in the sheet
Cells are visited in row-major order. SheetIndex, Row, e Col are 1-based public coordinates. Value is the current cell value. Formula contains the formula text for formula cells e is empty for ordinary value cells
Imposta Cancel to True nella callback per interrompere la scansione in anticipo. Il valore restituito è il numero di callback effettuate
Esempio
procedure TForm1.ReadCell(Sender: TObject; SheetIndex, Row, Col: Integer;
const Value: Variant; const Formula: WideString;
var Cancel: Boolean);
begin
Memo1.Lines.Add(Format('%d:%d = %s', [Row, Col, VarToStr(Value)]));
if Row >= 1000 then
Cancel := True;
end;
Visited := Workbook.Sheets[1].ForEachCell(ReadCell);
Vedere Also