+ Reply to Thread
Results 1 to 5 of 5

Automatically reading colors from Excel pie charts

  1. #1
    Registered User
    Join Date
    01-12-2022
    Location
    Europe
    MS-Off Ver
    Word, Excel (MSO 2016 V2111)
    Posts
    2

    Question Automatically reading colors from Excel pie charts

    Hello everyone,

    I would like to automate the task of retrieving the colors of pie chart slices inside an Excel (.xlsx) file. So far I tried the following approaches:

    Extract the .xlsx file such that I am left with the resulting .xml files, which carry the information of the spreadsheet. I was able to find the hex codes of the six accent colors for each theme used inside the spreadsheet. The colors of the slices of pie charts inside the spreadsheet are very similar to these colors, so I assumed the colors of the pie chart slices are based on these colors. Pie charts can have more than six colors, so Excel must automatically generate new colors to fill the slices of a pie chart having more than six slices. As mentioned, I could only find the six accent colors of the theme inside the unpacked .xml files but not all the colors of all the slices. The search was conducted using a regex of hex numbers over all the unpacked .xml files.

    My second approach was to google a code/formula that calculates the color of a slice in a pie chart based on the accent colors of the theme. Unfortunately, I could not find such code/ such a formula.

    So given a pie chart inside an Excel (.xlsx) file I would like to either automatically read the information of the colors from somewhere or calculate the colors based on information I can automatically retrieve from the Excel file. I want to emphasize that I am not asking for the whole solution to this problem but whether and how the color information of a pie chart in an Excel file can be found without manually looking them up inside Excel.

    Any help or ideas are appreciated.
    Thank you

  2. #2
    Valued Forum Contributor
    Join Date
    01-07-2022
    Location
    Europe
    MS-Off Ver
    Office 365
    Posts
    473

    Re: Automatically reading colors from Excel pie charts

    Are you able to make use of VBA?

    If so, a macro like this can be tailored to your needs. It runs through each category of the selected pie chart and reports the category name and RGB value


    Please Login or Register  to view this content.
    <<< If you have valued anyone's contributions in this thread, please click * to thank them for their efforts

  3. #3
    Registered User
    Join Date
    01-12-2022
    Location
    Europe
    MS-Off Ver
    Word, Excel (MSO 2016 V2111)
    Posts
    2

    Re: Automatically reading colors from Excel pie charts

    At first I did not want to make use of VBA. But I could not find a way to solve it without using VBA, so I'm going to try using VBA.
    Therefore, thanks for the solution I will definitely try.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,831

    Re: Automatically reading colors from Excel pie charts

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Valued Forum Contributor
    Join Date
    01-07-2022
    Location
    Europe
    MS-Off Ver
    Office 365
    Posts
    473

    Re: Automatically reading colors from Excel pie charts

    Two other methods of getting these values:

    1: (not sure if this is what you mean by manual)
    Select the portion of the pie chart you want to check
    Go to Fill > Color > More Colors

    2: Use an external tool. I use a very simple freeware tool called ColorPix https://colorpix.en.softonic.com/

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Formatting of colors and themes in excel charts
    By Jenkaldo in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 04-15-2019, 04:50 AM
  2. [SOLVED] Vary Colors in Pivot Charts based on values (Overlay Charts)
    By TitansGo in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 01-18-2017, 04:36 PM
  3. Excel 2010 - Cannot add colors to a charts data table
    By venetian_jigsaw in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-11-2011, 01:57 PM
  4. [SOLVED] how do you change the default colors in excel charts
    By cydney in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-26-2006, 04:10 PM
  5. [SOLVED] Controlling line colors/styles in excel charts
    By Rich in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-08-2006, 09:20 AM
  6. Why Excel changes colors of my charts ?
    By Ude in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-06-2005, 08:05 AM
  7. [SOLVED] Additional colors for Excel charts
    By Charlie in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 05-28-2005, 02:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1