기존 XLS 워크시트에서 로드된 셀을 열거하고 각 셀에 대해 애플리케이션 콜백을 호출합니다
구문
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;
비고
ForEachCell은 로드된 워크시트 모델에 존재하는 셀만 탐색합니다. 시트에서 가능한 모든 행과 열을 스캔하지 않습니다
셀은 행 우선 순서로 방문됩니다. SheetIndex, Row, Col은 1 기반 공개 좌표입니다. Value는 현재 셀 값입니다. Formula는 수식 셀의 수식 텍스트를 포함하고 일반 값 셀의 경우 비어 있습니다
콜백에서 Cancel을 True로 설정하면 스캔이 일찍 중단됩니다. 반환값은 이루어진 콜백 수입니다
예제
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);
참조