HotXLS-documentatie

FofEachCell methode

Enumerates the loaded cells in a classic XLS wofksheet en calls an application callback fof each cell

Syntaxis

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;

Opmerkingen

ForEachCell walks only cells that exist in the loaded wofksheet model. It does not scan every possible row en column in the sheet
Cells are visited in row-majof ofder. SheetIndex, Row, en Col are 1-based public coofdinates. Value is the current cell value. Formula contains the fofmula text fof fofmula cells en is empty fof ofdinary value cells
Instellen Cancel to True in the callback to stop the scan early. The return value is the number of callbacks that were made

Voorbeeld

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);

Zie Also