VBScript MS OWC enclosure code _vbs

Source: Internet
Author: User
Copy Code code as follows:

"' Owc.vbs
Class OWC
Private O
' Incoming object
Public Property Set Set_obj (O_ID)
Set o=o_id
End Property
' Paint a rectangular chart
' Chart_bgcolor_ the background color of the chart
' Chartcaption_ the title of the chart
' Chartcaption_fontcolor_ Chart title color
' Interior_color_ the fill color within the rectangle
' Caption_ name
' Categories_ name Array
' Values_ value Array string
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
' Set the background color or fill
O.charts (0). PlotArea.Interior.SetSolid Chart_bgcolor_

' Plus the title of the chart
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

' Add data
Cht. SetData c.chdimcategories, C.chdataliteral, Categories_
Cht. SeriesCollection (0). SetData c.chDimValues, C.chdataliteral, Values_
' The background color of the straight bar is set
Set Sc=o.charts (0). SeriesCollection (0)
Sc. Interior.color=interior_color_

' Display settings on the straight bar
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 = "0%"
' Left-percent property setting
Set CTA = Cht. Axes (C.chaxispositionleft)
Cta. Font.Size = 9
Cta. NumberFormat = "0%"
Cta. MajorUnit = 0.1
End Sub
' Multi-Series Rectangular chart
' Chart_bgcolor_ the background color of the chart
' Chartcaption_ the title of the chart
' Chartcaption_fontcolor_ Chart title color
' Color_ color array
' Caption_ name Array
' Categories_ name Array
' Values_ value Array
Public Sub Serbar (Chart_bgcolor_,chartcaption_,chartcaption_fontcolor_,color_,caption_,categories_,values_)
O.clear
O.charts.add
Set C = o.constants
' Type of chart
O.charts (0). type=c.chcharttypecolumnclustered
' Add background color to plot area
O.charts (0). PlotArea.Interior.SetSolid Chart_bgcolor_
"Plus the title of the chart
O.haschartspacetitle = True
O.chartspacetitle.caption = Chartcaption_
' Title's Properties
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
' Use loops to add seriescollection and content.
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 = "0%"
Next
"The setting of the legend
O.charts (0). HasLegend = True
O.charts (0). Legend.Font.Size = 9
O.charts (0). Legend.position = C.chlegendpositionbottom
' Left percent of the property setting
Set CTA = o.charts (0). Axes (C.chaxispositionleft)
Cta. Font.Size = 9
Cta. NumberFormat = "0%"
Cta. MajorUnit = 0.1
End Sub
' Draw a circle pie chart
' Chart_bgcolor_ plot area plus background color
' Chartcaption_ the title of the chart
' Chartcaption_fontcolor_ Chart title color
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
' Add background color to plot area
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 = "0%"
End Sub
' Stitch diagram
' Chart_bgcolor_ plot area plus background color
' Chartcaption_ the title of the chart
' Chartcaption_fontcolor_ Chart title color
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
' Add background color to plot area
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
' Multi-series Stitch diagram
' Chart_bgcolor_ the background color of the chart
' Chartcaption_ the title of the chart
' Chartcaption_fontcolor_ Chart title color
' Color_ color array
' Caption_ name Array
' Categories_ name Array
' Values_ value Array
Public Sub Serline (Chart_bgcolor_,chartcaption_,chartcaption_fontcolor_,color_,seriesnames_,categories_,values_)
O.clear
Set CHT = O.charts.add
Set C = o.constants
' Set Chart type
Cht. Type = C.chcharttypelinemarkers
' Add background color to plot area
O.charts (0). Plotarea.interior.color=chart_bgcolor_
' Plus title
O.haschartspacetitle = True
O.chartspacetitle.caption = Chartcaption_
O.chartspacetitle.font.color = Chartcaption_fontcolor_
O.chartspacetitle.font.name = "Arial"
O.chartspacetitle.font.size = 12
' Add data
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
' Clear pattern
Public Sub Clear ()
O.clear
End Sub
End Class

To use test code:
Copy Code code as follows:

<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", "Report title", "BLUE", "#CCCC00", "group", Categories,values

Color=array ("#CCFFFF", "#99CCFF", "#00CCFF", "#FF0000", "#660066", "#FF8080")
Caption=array ("1th Week", "2nd Week", "3rd Week", "4th Week")
Categories=array ("Building a", "Building 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", "October 2008 pit head three factory each week each floor to reach the rate comparison chart", "Red", color,caption,categories,values

Categories=array ("Taipei", "Shanghai")
Values = Array (238760,912560.62)
Set T.set_obj=document.getelementbyid ("CS3")
T.pie "#FFFFFF", "the proportion of sales (urban classification)", "BLUE", "City", 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", "Sales Amount", "BLUE", "date", categories,values

Color=array ("#CCFFFF", "#99CCFF", "#00CCFF", "#FF0000")
Seriesnames = Array ("A product", "B Product", "C Product", "D product")
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", "reach the rate of monthly Report", "Red", color,seriesnames,categories,values

Set t=nothing
End Sub
</script>
<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>

What is OWC?
The Office Web components is a group of COM controls designed to provide interactive spreadsheet modeling, data reporting, and data visualization for numerous control containers. The OWC library contains four main components: a Spreadsheet Component, a Chart component, a pivot table component, and a data source component.
The word "office" in the name "Office Web components" means that these controls were developed by a subset of the programmers who developed Microsoft Excel and access, and those controls were designed to look, Use feelings and behaviors like a streamlined version of their Microsoft Office brother. These controls do not contain all of the features in Excel and Access--in other words, you don't download the full Excel and access dynamically to view a report in a browser, and these controls do contain a number of common features, In particular, the functionality necessary to interact with existing content. In addition, the controls are able to read and write Excel 2000 HTML-formatted files, allowing users to click on a button to load the current data into Excel for more robust analysis.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.