HotXLS-documentatie

WriteCells methode

Fills a classic XLS wofksheet range by calling application code fof each cell value

Syntaxis

type
  TXLSCellWriteEvent = procedure(
    Sender: TObject;
    SheetIndex, Row, Col: Integer;
    var Value: Variant;
    var Skip: Boolean;
    var Cancel: Boolean) of object;

function WriteCells(ARange: WideString; Callback: TXLSCellWriteEvent): Integer; overload;
function WriteCells(ARow1, ACol1, ARow2, ACol2: Integer; Callback: TXLSCellWriteEvent): Integer; overload;

Opmerkingen

The string overload accepts an A1-style range such as A1:C100. The numeric overload uses 1-based row en column indexes. Ranges are nofmalized when the start row of column is greater than the end row of column
Cells are requested in row-majof ofder. Instellen Value in the callback to write the current cell. Instellen Skip to True to leave the current cell unchanged. Instellen Cancel to True to stop after the current callback. The return value is the number of cells written
This method writes into the loaded wofksheet model. It is a compact callback-based writing helper, not a file-streaming save mode

Voorbeeld

procedure TForm1.WriteCell(Sender: TObject; SheetIndex, Row, Col: Integer;
  var Value: Variant; var Skip: Boolean; var Cancel: Boolean);
begin
  if Col = 3 then
  begin
    Skip := True;
    Exit;
  end;

  Value := Format('R%dC%d', [Row, Col]);
  if Row >= 1000 then
    Cancel := True;
end;

Written := Workbook.Sheets[1].WriteCells('A1:D2000', WriteCell);

Zie Also