2017-06-10 30 views
1

我使用的Microsoft.Office.Interop.Excel,並生成一個excel數據 enter image description here如何在excel圖表中分組excel範圍?

我目前表示同該數據以Excel爲圖也是這樣: enter image description here

但我需要該數據分組如下: enter image description here

如何修改我的代碼來實現這一目標?

當前代碼

Dim chartDeliveryDetailDateRd As Excel.Chart 
Dim xlChartsDd As Excel.ChartObjects 
Dim myChartDdRd As Excel.ChartObject 
Dim chartRangeDdRd As Excel.Range 

xlChartsDd = xlWorkSheet3.ChartObjects 

myChartDdRd = xlChartsDd.Add(50, 100, 500, 250) 

chartDeliveryDetailDateRd = myChartDdRd.Chart 

chartRangeDdRd = xlWorkSheet3.Range("a1", "i4") 
chartDeliveryDetailDateRd.SetSourceData(Source:=chartRangeDdRd) 

chartDeliveryDetailDateRd.ChartType = Excel.XlChartType.xlColumnClustered 

回答

0

我找到解決方案,它的代碼實際上一行。

新增

chartDeliveryDetailDateRd.PlotBy = Excel.XlRowCol.xlColumns 

這將列在我的情況下得到的數據分組

繪製圖表