How to set a chart series title to a cell Reference instead of cell value?

54 views
Skip to first unread message

Larry FastCA

unread,
May 11, 2023, 12:28:22 PM5/11/23
to openpyxl-users

I'm trying to use a cell reference for my chart-series title. I can get the text from the cell but cannot create a reference to it.

I've tried the following:

pxl.chart.Series( ... title='=LiveData!$B$1'

ref = pxl.chart.Reference( sheet, min_col=1, min_row=1
pxl.chart.Series( ... title=ref )


When opening Excel, I was hoping for series title: =Sheet1!$B$1 - a live cell reference. Instead the latter solution gives me =''Sheet'!$B$1'

Larry FastCA

unread,
May 11, 2023, 9:19:59 PM5/11/23
to openpyxl-users
Got an answer from stackoverflow

from openpyxl.chart.series import Series, SeriesLabel
from openpyxl.chart.data_source import StrRef 
 series = Series(...)     # don't give it a title 
 series.title = SeriesLabel(strRef=StrRef("Sheet1!$B$1"))
Reply all
Reply to author
Forward
0 new messages