Public Sub SetChartOptions(ByVal iXlChartType As xlChartType, _
ByVal iPlotAreaWidth As Integer, ByVal iPlotAreaHeight As Integer)
With oExcelChart
.ChartType = iXlChartType
If (iPlotAreaHeight > 50) Then .PlotArea.Height = iPlotAreaHeight
If (iPlotAreaWidth > 50) Then .PlotArea.Width = iPlotAreaWidth
End With
End Sub
Sub SetChartTitles(strMainTitle, strXAxisTitle, strYAxisTitle)
On Error Resume Next
With oExcelChart
''''--- 检查并设置图表标题
If (Not IsNull(strMainTitle) And Trim(strMainTitle) < > "") Then
.HasTitle = True
.ChartTitle.Caption = strMainTitle
.ChartTitle.Font.Name = "Verdana"
.ChartTitle.Font.FontStyle = "Bold"
.ChartTitle.Font.Size = 14
End If
''''--- 检查并设置X-轴标题
If (Not IsNull(strXAxisTitle) And Trim(strXAxisTitle) < > "") Then
.Axes(xlCategory).HasTitle = True
.Axes(xlCategory).AxisTitle.Characters.Text = strXAxisTitle
.Axes(xlCategory).AxisTitle.Font.Name = "Verdana"
.Axes(xlCategory).AxisTitle.Font.FontStyle = "Bold"
.Axes(xlCategory).AxisTitle.Font.Size = 12
End If
''''--- 检查并设置Y-轴标题
If (Not IsNull(strYAxisTitle) And Trim(strYAxisTitle) < > "") Then
.Axes(xlValue).HasTitle = True
.Axes(xlValue).AxisTitle.Characters.Text = strYAxisTitle
.Axes(xlValue).AxisTitle.Font.Name = "Verdana"
.Axes(xlValue).AxisTitle.Font.FontStyle = "Bold"
.Axes(xlValue).AxisTitle.Font.Size = 12
''''--- 设置Y-轴标题的方向
.Axes(xlValue).AxisTitle.HorizontalAlignment = xlCenter
.Axes(xlValue).AxisTitle.VerticalAlignment = xlCenter
.Axes(xlValue).AxisTitle.Orientation = xlVertical
End If
End With
End Sub