TXlsFile.DeleteNamedRange Method
Deletes the name at the specified position. Important: If the name you are trying to delete is referenced by any formula/chart/whatever in your file, the name will not actually be deleted but hidden.
You won't see the name in Excel or in the formula, but it will be there and you can see it from FlexCel. You can use TExcelFile.GetUsedNamedRanges to learn if a range might be deleted. Also, note that if you later delete the formulas that reference those ranges FlexCel will remove those hanging ranges when saving. The only hidden ranges that will be present in the final file will be those that have active formulas referencing them.
Important:If the name wasn't deleted, TExcelFile.NamedRangeCount will not change. This means that you can't have code like this:
while xls.NamedRangeCount > 0 do //WRONG! This loop might never end.
begin
xls.DeleteNamedRange(1); //Might not be deleted, and NamedRangeCount will never be 0.
end;
The correct code in this case would be:
for i := xls.NamedRangeCount downto 1 do
xls.DeleteNamedRange(i);
Syntax
Unit: FlexCel.XlsAdapter
procedure TXlsFile.DeleteNamedRange(const index: Integer); override;
Parameters
<-> | Parameter | Type | Description |
---|---|---|---|
const | index | Integer | Index of the name to delete (1 based). |