7、支持函数

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 fleg 的 blog

最后我们再来看一下几个用来设置图表外观的函数。

   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属性实现。

本文关键:7、支持函数
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top