A Athanas
A Athanas

Reputation: 11

Assign chart tile a cell reference using openpyxl

In Excel you can create dynamic chart titles by selecting the chart title object and then in the formula bar linking it to a cell within your Excel workbook.

Using openpyxl to make a chart I can set the title but I am unsure of how to set the title as cell reference.

import openpyxl as xl

chart = xl.chart.BarChart()
chart.title = "Some Chart Title" #I'd like this to be "'Sheet1'!$A$1"

Upvotes: 0

Views: 815

Answers (1)

A Athanas
A Athanas

Reputation: 11

Solved it

# Initialize the title first
chart.title = "" 
chart.title.tx.strRef = xl.chart.data_source.StrRef( "'Sheet1'!$A$1")

Upvotes: 1

Related Questions