HotXLS 文件

FindText 方法

在已載入的傳統 XLS 文字儲存格中尋找包含指定文字的第一個儲存格

語法

function FindText(SearchText: WideString; out Row: Integer; out Col: Integer): Boolean; overload;
function FindText(SearchText: WideString; out Row: Integer; out Col: Integer; MatchCase: Boolean): Boolean; overload;

備註

FindText 以列優先順序掃描現有工作表儲存格,並傳回第一個符合項目的 1 起始公開列和欄座標
兩個參數的多載不區分大小寫。當搜尋必須精確比對原始大小寫時,請為 MatchCase 傳入 True。公式儲存格和非文字儲存格將被略過
若找不到符合項目,此方法傳回 False,並將兩個座標都設為零

範例

if Workbook.Sheets[1].FindText('[CONTACT]', Row, Col) then
  Workbook.Sheets[1].Cells[Row, Col].Value := 'John Smith';

另請參閱