下面是我的代碼,無法設置Excel圖表樣式
Public Sub createdonutchart(Chartrange1 As String, chartrange2 As String, L1 As Integer, T1 As Integer, W1 As Integer, H1 As Integer, targetsheet As Worksheet, charttitle As String)
Dim oChart As Excel.Chart
Dim MyCharts As Excel.ChartObjects
Dim MyCharts1 As Excel.ChartObject
MyCharts = targetsheet.ChartObjects
MyCharts1 = MyCharts.Add(L1, T1, W1, H1)
oChart = MyCharts1.Chart
With oChart
Dim chartRange As Excel.Range
chartRange = targetsheet.Range(Chartrange1, chartrange2)
.SetSourceData(chartRange)
.PlotBy = Excel.XlRowCol.xlColumns
.ChartType = Excel.XlChartType.xlDoughnut
.ChartStyle = 3
.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowNone)
.HasLegend = True
.Legend.Position = Excel.XlLegendPosition.xlLegendPositionRight
.HasTitle = True
.ChartTitle.Text = charttitle
End With
End Sub
我用chart.chartstyle = 3〜圖表樣式更改爲3,但是練成仍然顯示的圖表與基本圖表樣式見附件圖片。
沒有身體回答這個問題???? –