我已經編寫了代碼圖。現在我需要將趨勢線添加到該圖中。當我嘗試它。它給出了以下錯誤。'實例方法'對象沒有屬性'DisplayEquation'
Traceback (most recent call last):
File "C:\Users\jmp655972\Desktop\Python\test_1.py", line 87, in <module>
trend.DisplayEquation = True
AttributeError: 'instancemethod' object has no attribute 'DisplayEquation'
代碼:
worksheets = workbook.Sheets(1) chart= worksheets.Shapes.AddChart(72) print (chart)
worksheets.ChartObjects(1).Chart.HasTitle = True worksheets.ChartObjects(1).Chart.ChartTitle.Text = "Testing Samples"
trend =worksheets.ChartObjects(1).Chart.SeriesCollection(1).Trendlines().Add
trend.DisplayEquation = True
代碼是如下:worksheets.ChartObjects(1).Chart.HasTitle =真 worksheets.ChartObjects(1).Chart.ChartTitle.Text = 「測試樣品」 趨勢= worksheets.ChartObjects(1).Chart。 SeriesCollection(1).Trendlines()。添加 trend.DisplayEquation = True – Jay
您可以使用編輯按鈕編輯您的帖子,並放入您的代碼。 – usethedeathstar
代碼: 工作表= workbook.Sheets(1) 圖表= worksheets.Shapes.AddChart(72) 打印(圖表) worksheets.ChartObjects(1).Chart.HasTitle =真 worksheets.ChartObjects(1).Chart .ChartTitle.Text =「測試樣本」 trend = worksheets.ChartObjects(1).Chart.SeriesCollection(1).Trendlines()。Add trend.DisplayEquation = True – Jay