7、支持函数 (转)

7、支持函数 (转)[@more@]最后我们再来看一下几个用来设置图表外观的 函数

   SetChartOptions函数

   该函数用来设置图表类型、大小。

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

 
 

   该函数的目的是让用户设置一些重要的图表属性。另外,该函数也为开发者示范了如何在必要的时候显露图表属性使得用户可以访问它。本函数允许用户设置图表类型、图形区的高度和宽度,这些属性的默认值已经由SetChartBaseProps() 和SetChartWithDataProps()这两个函数设置过了。

   SetChartTitles函数

   该函数设置图表标题、X-轴和Y-轴标题。

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

 
 

   我们不再具体介绍该函数和后面几个函数的每行代码。该函数的目的是设置图表的各种标题:通过ChartTitile对象设置主标题,通过Axes对象设置X轴和Y轴的标题。窍门在于要设置好Y-轴标题的方向,这通过设置Aces对象内AxisTitle对象的Orientation属性实现。


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-988507/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10752043/viewspace-988507/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值