Getting delphi color values ​​for Excel lines

When Excel draws rows in a chart, it assigns default colors for the traces for each data series. Black for the first, blue for the second, etc. Is the assignment of these colors documented? I want to draw a trace on a graph using Delphi, but I want the colors to be the same as Excel (the Delphi application replaces the material that is currently being executed using Excel workbooks).

+3
source share
1 answer

The default values ​​are Graphic Fills and Line Chart from the menu: Tools β†’ Options β†’ Colors (at least when Excel has a menu - I don’t know about newer versions). The default color can be changed for each book, and therefore they are the property of the book. There are a total of 56 colors on the Color page, of which 8 are for filling diagrams and 8 are for diagram lines.

If you are doing automation, you can get the default color for the book:

TColor(XL.Workbooks[1].Colors[Index])

where "XL" is an excel application, "1" is the index of the workbook, and "Index" is a number from 1 to 56. A small test with an earlier version of excel shows index 17-24 - these are fill colors and 25-32 - color of the lines. But you do your own tests in case changes happen.

, , Delphi .

+3

Source: https://habr.com/ru/post/1779901/


All Articles