Sets the classic XLS AutoFilter range for the worksheet.
Syntax
procedure SetAutoFilter(ARow1, ACol1, ARow2, ACol2: Integer); overload;
procedure SetAutoFilter(ARange: WideString); overload;
Remarks
The numeric overload uses 1-based row and column indexes. The string overload accepts an A1-style range such as A1:C5. Saving as BIFF8 writes the worksheet AutoFilter records and the matching built-in filter database name.
To set a field condition while creating the range, call IXLSWorksheet.ApplyAutoFilter. To apply criteria to an existing range object, call IXLSRange.Autofilter(Field, Criteria) on the target range.
Example
Workbook := TXLSWorkbook.Create;
try
Sheet := Workbook.Sheets[1];
Sheet.SetAutoFilter('A1:C5');
Workbook.SaveAs('filtered.xls', xlExcel97);
finally
Workbook.Free;
end;
See Also