【问题标题】:Assign chart tile a cell reference using openpyxl使用 openpyxl 为图表平铺分配单元格引用
【发布时间】:2020-06-27 06:27:38
【问题描述】:

在 Excel 中,您可以通过选择图表标题对象,然后在公式栏中将其链接到 Excel 工作簿中的单元格来创建动态图表标题。

使用openpyxl制作图表我可以设置标题,但我不确定如何将标题设置为单元格引用。

import openpyxl as xl

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

【问题讨论】:

    标签: python excel openpyxl


    【解决方案1】:

    解决了

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

    【讨论】:

      猜你喜欢
      • 2010-11-13
      • 1970-01-01
      • 1970-01-01
      • 2017-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多