vbscript ms owc 封裝代码_vbs

复制代码 代码如下:

''owc.vbs
class owc
private o
'传入物件
public property set set_obj(o_id)
set o=o_id
end property
'画图矩形图
'chart_bgcolor_图表的背景颜色
'chartCaption_图表的标题
'chartCaption_fontColor_图表标题颜色
'Interior_Color_矩形内的填充颜色
'Caption_名称
'categories_名称数组
'values_值数组串
public sub bar(chart_bgcolor_,chartCaption_,chartCaption_fontColor_,Interior_Color_,Caption_,categories_,values_)
o.Clear
set cht = o.Charts.Add
set c = o.Constants
cht.Type = c.chChartTypeColumnClustered
'设背景色或是填充
o.Charts(0).PlotArea.Interior.SetSolid chart_bgcolor_

'加上图表的标题
o.HasChartSpaceTitle = True
set cst=o.ChartSpaceTitle
cst.Caption = chartCaption_
cst.Font.Color = chartCaption_fontColor_
cst.Font.Italic = False
cst.Font.Name = "Arial"
cst.Font.Size = 12
cst.Font.Underline = c.owcUnderlineStyleSingle

'添加数据
cht.SetData c.chDimCategories, c.chDataLiteral, categories_
cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_
'直条的背景色进行设定
set sc=o.Charts(0).SeriesCollection(0)
sc.Interior.Color=Interior_Color_

'直条上的显示设置
sc.Caption=Caption_
set dl = cht.SeriesCollection(0).DataLabelsCollection.Add
dl.HasValue = True
dl.HasPercentage = False
dl.Font.Size = 9
dl.Font.Color = "red"
dl.Position = c.chLegendPositionRight
dl.NumberFormat = "00.00%"
'左边百分比的属性设置
Set cta = cht.Axes(c.chAxisPositionLeft)
cta.Font.Size = 9
cta.NumberFormat = "0.0%"
cta.MajorUnit = 0.1
end sub
'多系列矩形图
'chart_bgColor_图表的背景颜色
'chartCaption_图表的标题
'chartCaption_fontColor_图表标题颜色
'color_颜色数组
'caption_名称数组
'categories_名称数组
'values_值数组
public sub serBar(chart_bgColor_,chartCaption_,chartCaption_fontColor_,color_,caption_,categories_,values_)
o.Clear
o.Charts.Add
Set c = o.Constants
'图表的类型
o.Charts(0).type=c.chChartTypeColumnClustered
'给绘图区加背景色
o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_
''加上图表的标题
o.HasChartSpaceTitle = True
o.ChartSpaceTitle.Caption = chartCaption_
'标题的属性
o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_
o.ChartSpaceTitle.Font.Italic = False
o.ChartSpaceTitle.Font.Name = "Arial"
o.ChartSpaceTitle.Font.Size = 12
o.ChartSpaceTitle.Font.Underline = c.owcUnderlineStyleSingle
'用循环来新增SeriesCollection以及里面的内容
for i=0 to ubound(caption_)
valuetemp=""
for j = i*(ubound(categories_)+1) to (i+1)*(ubound(categories_)+1)-1
valuetemp = valuetemp & "," & values_(j)
next
valuearr = split(mid(valuetemp,2),",")
o.Charts(0).SeriesCollection.Add
o.Charts(0).SeriesCollection(i).Caption = caption_(i)
o.Charts(0).SeriesCollection(i).Interior.Color = color_(i)
o.Charts(0).SeriesCollection(i).SetData c.chDimCategories, c.chDataLiteral, categories_
o.Charts(0).SeriesCollection(i).SetData c.chDimValues, c.chDataLiteral, valuearr
set dl = o.Charts(0).SeriesCollection(i).DataLabelsCollection.Add
dl.HasValue = True
dl.HasPercentage = False
dl.Font.Size = 9
dl.Font.Color = "red"
dl.Position = c.chLegendPositionRight
dl.NumberFormat = "00.00%"
next
''图例的设定
o.Charts(0).HasLegend = True
o.Charts(0).Legend.Font.Size = 9
o.Charts(0).Legend.Position = c.chLegendPositionBottom
''左边百分比的属性设置
Set cta = o.Charts(0).Axes(c.chAxisPositionLeft)
cta.Font.Size = 9
cta.NumberFormat = "0.00%"
cta.MajorUnit = 0.1
end sub
'画圆饼图
'chart_bgColor_绘图区加背景色
'chartCaption_图表的标题
'chartCaption_fontColor_图表标题颜色
public sub Pie(chart_bgColor_,chartCaption_,chartCaption_fontColor_,Caption_,categories_,values_)
o.Clear
Set cht = o.Charts.Add
Set c = o.Constants
cht.Type = c.chChartTypePie3d
'给绘图区加背景色
o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_
cht.ExtrudeAngle = 90
cht.ChartDepth = 169
cht.AspectRatio = 120
cht.Rotation =180
cht.Inclination=70

o.HasChartSpaceTitle = True
o.ChartSpaceTitle.Caption = chartCaption_
o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_
o.ChartSpaceTitle.Font.Name = "Arial"
o.ChartSpaceTitle.Font.Size = 12
o.ChartSpaceTitle.Font.Underline = c.owcUnderlineStyleSingle

cht.HasLegend = True
cht.Legend.Font.Size = 9
cht.Legend.Position = c.chLegendPositionBottom

cht.SetData c.chDimCategories, c.chDataLiteral, categories_
cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_
set sc=o.Charts(0).SeriesCollection(0)
sc.Caption=Caption_
Set dl = cht.SeriesCollection(0).DataLabelsCollection.Add
dl.Separator = ":"
dl.HasValue = false
dl.HasSeriesName = false
dl.HasCategoryName=true
dl.HasPercentage = true
dl.Font.Size = 9
dl.Font.Color = "red"
dl.NumberFormat = "00.00%"
end sub
'拆线图
'chart_bgColor_绘图区加背景色
'chartCaption_图表的标题
'chartCaption_fontColor_图表标题颜色
public sub line(chart_bgColor_,chartCaption_,chartCaption_fontColor_,Caption_,categories_,values_)
o.Clear
Set cht = o.Charts.Add
Set c = o.Constants
cht.Type = c.chChartTypeLineMarkers
'给绘图区加背景色
o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_
o.HasChartSpaceTitle = True
o.ChartSpaceTitle.Caption = chartCaption_
o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_
o.ChartSpaceTitle.Font.Name = "Arial"
o.ChartSpaceTitle.Font.Size = 12
o.ChartSpaceTitle.Font.Underline = c.owcUnderlineStyleSingle

cht.SetData c.chDimCategories, c.chDataLiteral, categories_
cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_

set sc=o.Charts(0).SeriesCollection(0)
sc.Caption=Caption_
Set dl = cht.SeriesCollection(0).DataLabelsCollection.Add
dl.HasValue = True
dl.HasPercentage = False
dl.Font.Size = 9
dl.Font.Color = "red"

Set categoryAxis = cht.Axes(c.chAxisPositionBottom)
categoryAxis.Font.Size = 9

Set categoryAxis = cht.Axes(c.chAxisPositionLeft)
categoryAxis.Font.Size = 9
end sub
'多系列拆线图
'chart_bgColor_图表的背景颜色
'chartCaption_图表的标题
'chartCaption_fontColor_图表标题颜色
'color_颜色数组
'caption_名称数组
'categories_名称数组
'values_值数组
public sub serLine(chart_bgColor_,chartCaption_,chartCaption_fontColor_,color_,SeriesNames_,categories_,values_)
o.Clear
Set cht = o.Charts.Add
Set c = o.Constants
'设置图表类型
cht.Type = c.chChartTypeLineMarkers
'给绘图区加背景色
o.Charts(0).PlotArea.Interior.Color=chart_bgColor_
'加上标题
o.HasChartSpaceTitle = True
o.ChartSpaceTitle.Caption = chartCaption_
o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_
o.ChartSpaceTitle.Font.Name = "Arial"
o.ChartSpaceTitle.Font.Size = 12
''添加数据
cht.SetData c.chDimSeriesNames, c.chDataLiteral, SeriesNames_
cht.SetData c.chDimCategories, c.chDataLiteral, Categories_

set categoryAxis = cht.Axes(c.chAxisPositionBottom)
categoryAxis.Font.Size = 9

Set categoryAxis = cht.Axes(c.chAxisPositionLeft)
categoryAxis.Font.Size = 9

for i = 0 to ubound(SeriesNames_)
valuetemp = ""
for j = i*(ubound(Categories_)+1) to (i+1)*(ubound(Categories_)+1)-1
valuetemp = valuetemp & "," & values_(j)
next
valuearr = split(mid(valuetemp,2),",")
cht.SeriesCollection(i).SetData c.chDimValues, c.chDataLiteral, valuearr
cht.SeriesCollection(i).Line.Color = color_(i)
cht.SeriesCollection(i).Line.Weight = c.owcLineWeightThin
cht.SeriesCollection(i).Marker.Style = c.chMarkerStyleDiamond
cht.SeriesCollection(i).Interior.Color = color_(i)
Set dl = cht.SeriesCollection(i).DataLabelsCollection.Add
dl.HasValue = true
dl.HasPercentage = false
dl.Font.Size = 9
dl.font.color="red"
next
end sub
'清除图型
public sub clear()
o.Clear
end sub
end class

使用测试代码:

复制代码 代码如下:

<html>
<head>
<title>vbscript owc class test</title>
<script language="vbscript" src="owc.vbs"></script>
<script language="vbscript">
sub window_onload()
set t = new owc

categories =Array("A2-1","A2-2","A2-3","A3-1","A3-2","A3-3"_
,"B2-1","B2-2","B2-3","B3-1","B3-2","B3-3"_
,"C2-1","C2-2","C3-1","C3-2","C3-3")
values = Array(0.813,0.689,0.800,0.833,0.681,0.864,0.743_
,0.894,0.822,0.874,0.746,0.908,0.850_
,0.728,0.731,0.734,0.624)
set t.set_obj=document.getElementById("cs1")
t.bar "#FFFFFF","报表标题","BLUE","#CCCC00","组别",categories,values

color=Array("#CCFFFF","#99CCFF","#00CCFF","#FF0000","#660066","#FF8080")
caption=Array("第1周","第2周","第3周","第4周")
categories=Array("A栋","B栋")
values=Array(0.6951,0.5798,0.7075,0.512,0.7907,0.7493,0.8691,0.7716)
set t.set_obj=document.getElementById("cs2")
t.serbar "#FFFFFF","2008年10月坑头三厂各周各楼层达成率比较图","red",color,caption,categories,values

categories=array("台北","上海")
values = array(238760,912560.62)
set t.set_obj=document.getElementById("cs3")
t.Pie "#FFFFFF","销售金额所佔比例(城市分类)","BLUE","城市",categories,values

categories =array("2008/11/1","2008/11/2","2008/11/3","2008/11/4","2008/11/5","2008/11/6","2008/11/7","2008/11/8","2008/11/9","2008/11/10","2008/11/11","2008/11/12","2008/11/13","2008/11/14","2008/11/15","2008/11/16","2008/11/17","2008/11/18","2008/11/19","2008/11/20","2008/11/21","2008/11/22","2008/11/23","2008/11/24","2008/11/25","2008/11/26","2008/11/27","2008/11/28","2008/11/29","2008/11/30")
values = array(67239.89,60400.26,7202.89,18453.12,28889.29,102136.25,78826.39,146291.6,93743.29,44204.44,45349.28,50730.6,37900.21,84359.87,169333.62,114594.96,75334.77,51360.32,55853.05,37912.63,45068.22,63930.98,72993.71,18699.5,24714.5,34792.91,39414.58,92171.2,74433.06,3998894.41)
set t.set_obj=document.getElementById("cs4")
t.line "#FFFFFF","销售金额","BLUE","日期",categories,values

color=Array("#CCFFFF","#99CCFF","#00CCFF","#FF0000")
SeriesNames = array("A产品","B产品","C产品","D产品")
Categories = array("2005/3/24","2005/3/25","2005/3/26","2005/3/27","2005/3/28")
values = array(50,100,20,80,89,40,60,20,90,70,20,50,55,25,60,80,20,75,58,100)
set t.set_obj=document.getElementById("cs5")
t.serline "#FFFFFF","达成率月报表","red",color,SeriesNames,categories,values

set t=nothing
end sub
</script>
</head>
<body>
<div id="c1"><object id="cs1" name="cs1" classid="CLSID:0002E55D-0000-0000-C000-000000000046" codebase="owc11.dll" style="width:100%;height:350"></object></div>
<div id="c2"><object id="cs2" name="cs2" classid="CLSID:0002E55D-0000-0000-C000-000000000046" codebase="owc11.dll" style="width:100%;height:350"></object></div>
<div id="c3"><object id="cs3" name="cs3" classid="CLSID:0002E55D-0000-0000-C000-000000000046" codebase="owc11.dll" style="width:100%;height:350"></object></div>
<div id="c4"><object id="cs4" name="cs4" classid="CLSID:0002E55D-0000-0000-C000-000000000046" codebase="owc11.dll" style="width:100%;height:350"></object></div>
<div id="c5"><object id="cs5" name="cs5" classid="CLSID:0002E55D-0000-0000-C000-000000000046" codebase="owc11.dll" style="width:100%;height:350"></object></div>
</body>
</html>

owc是什么?
Office Web Components是一组的COM控件,设计的目的是为众多的控件容器提供交互的电子表格建模,数据报表和数据可视化功能。OWC库包含四个主要的组件:电子表格组件,图表组件,透视表组件和数据源组件。
  “Office Web Components”名称中的单词”Office”表示这些控件就是由那些开发微软Excel和Access的程序员中的一部分人开发的,并且这些控件被设计成在外观,使用感受和行为表现上就像是他们的微软Office兄弟的精简版一样。这些控件确实不包含Excel和Access中的所有的功能——换句话说,你也不会为了在浏览器中查看一个报表而动态的下载完整的Excel和Access,这些控件也确实包含了许多的常用功能,尤其是那些在与已有内容进行交互时所必需的功能。此外,这些控件还能够读写Excel 2000的HTML格式的文件,允许用户点击一个按钮,将当前的数据加载到Excel中,以便作更加强大的分析。

时间: 2024-11-13 08:11:26

vbscript ms owc 封裝代码_vbs的相关文章

IE中用VBScript不提示直接打印的代码_vbs

首先在HTML 页面中加入WebBrowser 的Object: <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT> 之后,使用如下代码进行打印: <script language="VBScript"> sub printvb() wb.execwb 6,2,3 End Sub

vbscript自动配置IIS的代码_vbs

复制代码 代码如下: strServerName =""localhost"" strRootPath=""g:\documents"" ''虚拟目录路径 strVRName=""Test"" ''虚拟目录名称 strDefaultDoc=""index.asp"" ''起始文档 Dim objIIS ''MsgBox ""II

VBScript Enun Remote CMD Shell代码_vbs

效果如图: 复制代码 代码如下: '============================' Enun Remote CMDShell v 1.0'============================ Option Explicit CONST ACCOUNT_LOCK_TIME = 600000    '账户锁定时间,10分钟CONST LOCKOUT_BAD_COUNT = 3     '密码失败次数CONST DEFAULT_WAIT_TIME = 1000     '默认延时,1秒

javascript方法封裝問題

问题描述 javascript方法封裝問題 我想寫個方法類似於jquery的這種寫法 $(id).click(function(){ }) 这样写為什麼不行 應該怎麼寫 window.$=function(id){ return document.getElementById(id); } $.click=function(f){ $.attachEvent("onclick",f()); } 解决方案 这思路是不对的. window.$=function(id){ // window

VbScript 封裝MS OWC(二)_vbs

复制代码 代码如下: ''OWC1.VBS class owc private o '傳入物件 public sub create(id_,width_,height_,location_) Set o = document.createElement("object") o.setAttribute "id",id_ o.setAttribute "classid","CLSID:0002E55D-0000-0000-C000-000

vbscript include的办法实现代码第1/2页_vbs

任何真正实用的工程开发都必然是多文件的.但是VBScript创建多文件工程要麻烦一点,它对多文件工程,代码复用的支持并不是太好.在C/C++工程里,我们已经习惯了通过一个include语句,并且声明一个函数原形的方式来使用其它模块中的函数,这样一个复杂的工程可以比较容易地分解成一些小的模块,以更容易理解和掌握.VBScript中情况有些不同.这与它的设计目标有关.最初VBScript是用在客户端脚本,以支持与客户端作简单的交互,如简单的输入检查等等.在浏览器里显然没有办法支持对另一个文件中的函数

妙用VBScript自制IE工具栏按钮的代码_vbs

IE工具栏上的各种按钮可不是Microsoft的专利,普通用户一样能够对其进行自定义,添加想设置的按钮,至于添加的方法,很多资料上都介绍过.具体的实现方式不外乎两种,一是使用冗长且复杂的VC或VB代码程序,这对普通用户来说要求是过高了一点,通常搞得人满头雾水而不达目的:二是用手工的方法来完成,但是这种方法因为要大幅度地修改系统注册表,系统极不安全,一不小心就会弄巧成拙,让你重新安装系统!  我这里介绍一个折衷的方法,用VBScript自制IE工具栏按钮,它既不需要冗长复杂的程序代码,又不需要繁琐

VBScript教程 第二课在HTML页面中添加VBscript代码_vbs

VB教程 > 第二课在HTML页面中添加VBscript代码 SCRIPT 元素用于将 VBScript 代码添加到 HTML 页面中. <SCRIPT> 标记 VBScript 代码写在成对的 <SCRIPT> 标记之间.例如,以下代码为一个测试传递日期的过程: <SCRIPT LANGUAGE="VBScript"> <!--Function CanDeliver(Dt)CanDeliver = (CDate(Dt) - Now())

海阳顶端网进百度blog必须输入密码的vbscript代码_vbs

要看懂下面的代码,需要了解下面的函数vbscript strreverse 函数 返回字符串,此字符串与指定字符串顺序相反. strreverse(string1) string1 参数是要进行字符反向的字符串.如果 string1 是零长度字符串 (""),则返回零长度字符串.如果 string1 为 null,则会出现错误. 说明 下面的示例利用 strreverse 函数返回按相反顺序排列的字符串: dim mystr mystr = strreverse("vbscr