Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to get excel chart's main title text using python openpyxl library

Using the Python module openpyxl, I’m attempting to obtain the excel chart’s main title.

I need your assistance writing the script.

For example, the chart title "Test" is below. I want to retrieve this title and put it in a Python variable.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

>Solution :

Specifically, you want something like this;

import openpyxl

# Load the Excel workbook
workbook = openpyxl.load_workbook(r"chart.xlsx")

# Access the sheet containing the chart
sheet = workbook['charts - APAC']  # Replace with your sheet name

# Iterate through all charts in the sheet
for chart in sheet._charts:
    titlec = chart.title.text.rich.p[0].text[0].value
    print(titlec)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading