2014-01-29 136 views
1

我動態創建一些Excel圖表數據/系列,並且無法設置軸標題字體顏色/大小。在Excel中設置Excel圖表軸標題顏色和大小#

我能夠用代碼添加軸標題類似如下:

//Gets the WorkSheet and ChartObject 
Worksheet DataSheet = (Worksheet)Template.Worksheets[1]; 
Chart Graph = (DataSheet.ChartObjects(1) as ChartObject).Chart; 

//Gets the Axes 
Axis Xaxis = Graph.Axes(XlAxisType.xlCategory, XlAxisGroup.xlPrimary) as Axis; 
Axis Y1axis = Graph.Axes(XlAxisType.xlValue, XlAxisGroup.xlPrimary) as Axis; 
Axis Y2axis = Graph.Axes(XlAxisType.xlValue, XlAxisGroup.xlSecondary) as Axis; 

//Sets X-axis attributes 
Xaxis.TickLabels.Font.Size = 8; 
Xaxis.HasTitle = true; 
Xaxis.AxisTitle.Text = "Current (A)"; 

//Sets Y-Primary Axis attributes 
Y1axis.TickLabels.Font.Size = 8; 
Y1axis.HasTitle = true; 
Y1axis.AxisTitle.Text = "Power (W)"; 

//Sets Y-Secondary Axis attributes 
Y2axis.TickLabels.Font.Size = 8; 
Y2axis.HasTitle = true; 
Y2axis.AxisTitle.Text = "Voltage (V)"; 

但我無法揣摩出的顏色,字體大小,粗體,等等屬性。

回答

2

我在找了幾個小時後才找到它。

Y1axis.AxisTitle.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = XlRgbColor.rgbDarkRed; 

我只是不得不挖掘更遠一點。

相關問題