我的编程空间,编程开发者的网络收藏夹
学习永远不晚

VbScript如何封裝MS OWC

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

VbScript如何封裝MS OWC

这篇文章主要介绍VbScript如何封裝MS OWC,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

代码如下:


''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-000000000046"
o.setAttribute codebase="owc11.dll"
o.style.width=width_
o.style.height=height_
document.getElementById(location_).appendChild(o)
end sub
'畫圖矩形圖
'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" class="lazy" data-src="owc1.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)
t.create "cs1","100%","400px","c1"
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)
t.create "cs2","100%","400px","c2"
t.serbar "#FFFFFF","2008年10月坑頭三廠各周各樓層達成率比較圖","red",color,caption,categories,values

categories=array("臺北","上海")
values = array(238760,912560.62)
t.create "cs3","100%","400px","c3"
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)
t.create "cs4","100%","400px","c4"
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)
t.create "cs5","100%","400px","c5"
t.serline "#FFFFFF","達成率月報表","red",color,SeriesNames,categories,values

set t=nothing
end sub
</script>
</head>
<body>
<div id="c1"></div>
<div id="c2"></div>
<div id="c3"></div>
<div id="c4"></div>
<div id="c5"></div>
</body>
</html>

以上是“VbScript如何封裝MS OWC”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注编程网行业资讯频道!

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

VbScript如何封裝MS OWC

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

VbScript如何封裝MS OWC

这篇文章主要介绍VbScript如何封裝MS OWC,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!代码如下:OWC1.VBS class owc private o 傳入物件 public sub create(id
2023-06-08

vbscript ms owc如何封裝

小编给大家分享一下vbscript ms owc如何封裝,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!代码如下:owc.vbs class owc private
2023-06-08

如何用vbscript来添加ip策略自动封IP

本篇内容介绍了“如何用vbscript来添加ip策略自动封IP”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!程序主要是读取这个网站的iis日
2023-06-08

编程热搜

  • Python 学习之路 - Python
    一、安装Python34Windows在Python官网(https://www.python.org/downloads/)下载安装包并安装。Python的默认安装路径是:C:\Python34配置环境变量:【右键计算机】--》【属性】-
    Python 学习之路 - Python
  • chatgpt的中文全称是什么
    chatgpt的中文全称是生成型预训练变换模型。ChatGPT是什么ChatGPT是美国人工智能研究实验室OpenAI开发的一种全新聊天机器人模型,它能够通过学习和理解人类的语言来进行对话,还能根据聊天的上下文进行互动,并协助人类完成一系列
    chatgpt的中文全称是什么
  • C/C++中extern函数使用详解
  • C/C++可变参数的使用
    可变参数的使用方法远远不止以下几种,不过在C,C++中使用可变参数时要小心,在使用printf()等函数时传入的参数个数一定不能比前面的格式化字符串中的’%’符号个数少,否则会产生访问越界,运气不好的话还会导致程序崩溃
    C/C++可变参数的使用
  • css样式文件该放在哪里
  • php中数组下标必须是连续的吗
  • Python 3 教程
    Python 3 教程 Python 的 3.0 版本,常被称为 Python 3000,或简称 Py3k。相对于 Python 的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0 在设计的时候没有考虑向下兼容。 Python
    Python 3 教程
  • Python pip包管理
    一、前言    在Python中, 安装第三方模块是通过 setuptools 这个工具完成的。 Python有两个封装了 setuptools的包管理工具: easy_install  和  pip , 目前官方推荐使用 pip。    
    Python pip包管理
  • ubuntu如何重新编译内核
  • 改善Java代码之慎用java动态编译

目录