Table of Contents

TXlsFile.NearestColorIndex Method

Overloads

TXlsFile.NearestColorIndex(TUIColor)

Returns the most similar entry on the excel palette for a given color.

Syntax

Unit: FlexCel.XlsAdapter

function TXlsFile.NearestColorIndex(const value: TUIColor): Integer; overload; override;

Parameters

<-> Parameter Type Description
const value TUIColor Color we want to use.

Returns

Most similar color on the Excel palette.

See also

TXlsFile.NearestColorIndex(TUIColor, BooleanArray)

IMPORTANT: Since FlexCel 5.1, using TExcelFile.OptimizeColorPalette before saving should normally be used instead of this method to get an optimized palette. Just enter the true colors in FlexCel, and call TExcelFile.OptimizeColorPalette before saving.

Returns the most similar entry on the excel palette for a given color. If UsedColors is not null, it will try to modify the Excel color palette to get a better match on the color, modifying among the not used colors. Note that modifying the standard palette might result on a file that is not easy to edit on Excel later, since it does not have the standard Excel colors.

Syntax

Unit: FlexCel.XlsAdapter

function TXlsFile.NearestColorIndex(const value: TUIColor; const UsedColors: TArray<Boolean>): Integer; overload; override;

Parameters

<-> Parameter Type Description
const value TUIColor Color we want to use.
const UsedColors TArray<Boolean> If null, this behaves like the standard NearestColorIndex.
To get a list of used colors for the first call, use TExcelFile.GetUsedPaletteColors.
After the first call, keep using the same UsedColors structure and do not call GetUsedPaletteColors again, to avoid overwriting colors that are not yet inserted into the xls file with new ones. You can call GetUsedPaletteColors only after you added the format with TExcelFile.AddFormat

Returns

Most similar color on the Excel palette.

See also