[英]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.在 Excel 中,您可以通过选择图表标题 object 然后在公式栏中将其链接到 Excel 工作簿中的单元格来创建动态图表标题。
Using openpyxl to make a chart I can set the title but I am unsure of how to set the title as cell reference.使用 openpyxl 制作图表我可以设置标题,但我不确定如何将标题设置为单元格引用。
import openpyxl as xl
chart = xl.chart.BarChart()
chart.title = "Some Chart Title" #I'd like this to be "'Sheet1'!$A$1"
Solved it解决了
# Initialize the title first
chart.title = ""
chart.title.tx.strRef = xl.chart.data_source.StrRef( "'Sheet1'!$A$1")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.