Reputation: 11
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
Reputation: 11
Solved it
# Initialize the title first
chart.title = ""
chart.title.tx.strRef = xl.chart.data_source.StrRef( "'Sheet1'!$A$1")
Upvotes: 1