OWC资料收集-OWC简介及其属性

来源:互联网 发布:samsung kies软件下载 编辑:程序博客网 时间:2024/06/09 17:59
Figure 3 Office Web Components (version 10)

组件 描述 PivotTable 使用户连接到支持 OLE DB Provider for OLAP Services 8.0 或更高版的 OLAP 数据源上 (也可连接到 Excel 电子数据表单 和 SQL Server 、 Access 关系数据库)。PivotTable 控件允许用户对数据进行透视、分组、筛选和排序等操作。 Spreadsheet 提供电子数据表单用户接口,包括重算引擎和扩展函数库。 Chart 图形化显示来自某个绑定数据源、PivotTable 或 Spreadsheet 控件的数据。当 Chart 组件被绑定到 PivotTable 控件且用户重新透视数据时能自动刷新。 DataSource 管理与后台数据库服务器的通讯。PivotTable 和 Spreadsheet 组件实际上能单独连接到数据源,,不一定非得要 DataSource 组件。这是因为其 XML 数据可以直接包含 OLE DB 连接串。
Figure 4 PivotTable and Chart-related Objects

成员 描述 PivotTable 使用户连接到支持 OLE DB Provider for OLAP Services 8.0 或更高版的 OLAP 数据源上 (也可连接到 Excel 电子数据表单 和 SQL Server 、 Access 关系数据库)。PivotTable 控件允许用户对数据进行透视、分组、筛选和排序等操作。 PivotView 表示 PivotTable 的一个特定视图. 用于对 PivotTable 视图中的行、列、标尺、格式化进行设置。 PivotDataAxis 包含与数据轴相关的方法和属性 PivotResultColumnAxis 包含与列轴相关的方法和属性 PivotResultRowAxis 包含与行轴相关的方法和属性 PivotFieldSet 多维数据集中定义的字段集 PivotField 多维数据集中定义的字段 ChartSpace 使用户连接到支持 OLE DB Provider for OLAP Services 8.0 或更高版的任何 OLAP 数据源上,(也可连接到 Excel 电子数据表单和 SQL Server、Access 关系数据库)。ChartSpace 允许用户图形化显示数据并且将控件绑定到一个已存在的 PivotTable 或 Spreadsheet。 ChCharts ChChart 对象集合 ChChart ChartSpace 中的单个图表,一个ChartSpace 可容纳多达64个图表。
Figure 5 PivotTable Component's Programmatic Interface

成员 类型 描述 ActiveView 属性 表示一个活动的 PivotTable 布局。该属性返回一个 PivotView 对象。 ColumnAxis 属性 表示列轴中的字段。返回一个 PivotAxis 对象。 ConnectionString 属性 设置连接到 Analysis Services 服务器的连接字符串,ConnectionString 属性中的 DataSource 参数决定了 OWC 组件将要使用的连接协议。 DataAxis 属性 表示数据轴的规模。返回一个 PivotAxis 对象。 DataMember 属性 设置控件将要从 Analysis Services 请求的数据源名称。它与多维数据集同名。 IncludedMembers 属性 定义了 PivotField 内的数据成员。该属性接受的参数为单一成员或成员数组。 IsIncluded 属性 设置所包含的字段并激活 PivotFieldSet。 RowAxis 属性 表示行轴中的字段,返回 PivotAxis 对象。 XMLData 属性 设置或返回当前用于 PivotTable 报表控件的 XML 数据。有关报表的细节 (格式和数据) 均保存在 XML 数据中。也包括了 OLAP 连接详细信息。 AddCustomGroupField 方法 为指定的 PivotFieldSet 添加一个定制的分组字段。 AddCustomGroupMember 方法 为指定的 PivotFieldSet 添加一个定制的分组成员。 InsertFieldSet 方法 在行或列轴中插入一个字段集。 CommandExecute 事件 在某个命令执行之后触发,ChartCommandIdEnum 和PivotCommandId 常量包含用于每个 OWC 组件所支持的命令清单。 Query 事件 PivotTable 激活某个查询时触发。
Figure 6 Chart Component's Programmatic Interface

成员 类型 描述 DataSource 属性

 

为 Chart 控件定义数据源。当设置另一个控件(如:PivotTable 或 Spreadsheet)这样有效地绑定 Chart 控件到其它控件。 Type 属性

 

象 ChartChartTypeEnum 枚举所定义的那样定义图表类型,默认类型为条形图。
Figure 8 Connecting to an OLAP Data Source
function initializePivotTable(strDataMember) {// This function calls the InitializePivotTableXML() Web// methodvar iCallID = service.svcOLAP.callService(onInitializePivotTableResult,'InitializePivotTableXML',strDataMember);}function onInitializePivotTableResult(result) {// This function handles the InitializePivotTableXML()// Web method resulttext = result.value; // result string// Evaluate return resultif (!result.error) {// Assign the XML to the PivotList XMLData valuefrm1.PivotTable1.XMLData = text;}else {alert("Unhandled error - " + result.errorDetail.code +" " + result.errorDetail.string);}}

Figure 9 Generate XMLData for a PivotTable Control
<WebMethod()> Public Function InitializePivotTableXML(ByVal _strDataMember As String) As StringDim m_XML As StringDim strOLAPConn As String = _ConfigurationSettings.AppSettings("OLAPConnectionString")TryDim objPT As PivotTableClass = New PivotTableClassobjPT.ConnectionString = strOLAPConnobjPT.DataMember = strDataMemberm_XML = objPT.XMLDataobjPT = NothingCatch err As Exceptionm_XML = "<err>" & err.Source & " - " & err.Message & _"</err>"FinallyEnd TryReturn (m_XML)End Function

Figure 10 LoadCustomPivotTableReport Web Method
<WebMethod()> Public Function LoadCustomPivotTableReport(ByVal _strCity1 As String, ByVal strCity2 As String) As StringDim m_XML As StringDim strOLAPConn As String = _ConfigurationSettings.AppSettings("OLAPConnectionString")Dim objPT As PivotTableClass = New PivotTableClassDim objPTView As PivotViewDim fldCity, fldName, fldProdFamily As PivotFieldDim fSetCustomers, fSetProduct As PivotFieldSetTryobjPT.ConnectionString = strOLAPConnobjPT.DataMember = "Sales"objPT.AllowFiltering = FalseobjPTView = objPT.ActiveViewobjPTView.TitleBar.Caption = "City Comparison of DrinkSales"' Define the column elementsobjPTView.ColumnAxis.InsertFieldSet(objPTView.FieldSets("Time"))objPTView.ColumnAxis.FieldSets("Time").Fields("Year").Expanded = True' Define the row elementsfSetCustomers = objPTView.FieldSets("Customers")objPTView.RowAxis.InsertFieldSet(fSetCustomers)fSetCustomers.Fields("Country").IsIncluded = FalsefSetCustomers.Fields("State Province").IsIncluded = FalsefSetCustomers.Fields("Name").IsIncluded = False' Define the members of the row elementsfldCity = fSetCustomers.Fields("City")fldCity.IncludedMembers = New Object() {strCity1, strCity2}' Exclude all other field row members in the fieldsetfSetProduct = objPTView.FieldSets("Product")objPTView.RowAxis.InsertFieldSet(fSetProduct)fSetProduct.Fields("Product Department").IsIncluded = FalsefSetProduct.Fields("Product Category").IsIncluded = FalsefSetProduct.Fields("Product Subcategory").IsIncluded =FalsefSetProduct.Fields("Brand Name").IsIncluded = FalsefSetProduct.Fields("Product Name").IsIncluded = FalsefldProdFamily = fSetProduct.Fields("Product Family")fldProdFamily.IncludedMembers = "Drink"' Define the measuresobjPTView.DataAxis.InsertTotal(objPTView.Totals("Store Sales"))objPTView.DataAxis.Totals("Store Sales").NumberFormat = _"Currency"' Return the XML data to the client side scriptm_XML = objPT.XMLDataobjPT = NothingCatch err As Exceptionm_XML = "<err>" & err.Source & " - " & err.Message & "</err>"FinallyEnd TryReturn (m_XML)End Function

Figure 11 Load the XMLData for a Custom Report
function LoadSavedReport() {// Purpose:  Call Web Service method to load the saved// reportvar iCallID = service.svcOLAP.callService(onLoadSavedReportResult,'LoadSavedReport', 'OLAPReport1.xml');}function onLoadSavedReportResult(result) {// Purpose: This function handles the// wsOLAP.onLoadSavedReportResult() Web Service resultvar text = result.value; // result string// Evaluate return resultif (!result.error) {// Assign the XML to the PivotList XMLData valuefrm1.PivotTable1.XMLData = text;}}

Figure 12 JavaScript and VBScript Event Handler
<script language="javascript" event="Query" for="PivotTable1">{var sLog = document.Form1.Text1.value + "";document.Form1.Text1.value = "Query Event Fired. " + sLog;}</script><script language="vbscript">Sub PivotTable1_CommandExecute(Command, Succeeded)Dim ptConstantsSet ptConstants = document.Form1.PivotTable1.Constants' Check to see if the PivotTable list has been' refreshed.If Command = ptConstants.plCommandRefresh Then' Write the current data and time to the text box.document.Form1.Text1.value = vbCrLf & _"PivotTable Last Refreshed on " & Date & " at " _& Time & vbCrLf & document.Form1.Text1.valueEnd IfEnd Sub</script>

Figure 13 Creating Custom Groups
<WebMethod()> Public Function ApplyCustomGrouping(ByVal _strReportXMLData As String) As StringDim m_xml As StringDim objPT As PivotTableClass = New PivotTableClassDim objPTView As PivotViewDim fsTime As PivotFieldSetDim fsHalfYear As PivotFieldTryobjPT.XMLData = strReportXMLDataobjPTView = objPT.ActiveView' Set a variable to the Time field set.fsTime = objPTView.FieldSets("Time")' Add a custom group field named "Group1" to the Time field' set.fsHalfYear = fsTime.AddCustomGroupField("CustomGroup1", _"CustomGroup1", "Quarter")' Add a custom field set member. This member includes all' "Q1" and "Q2" members under 1997.fsHalfYear.AddCustomGroupMember _(fsTime.Member.ChildMembers("1997").Name, _New Object() {"Q1", "Q2"}, "1stHalf")' Add another custom fieldset member to include all "Q3"' and "Q4" members under 1997.fsHalfYear.AddCustomGroupMember _(fsTime.Member.ChildMembers("1997").Name, _New Object() {"Q3", "Q4"}, "2ndHalf")' Collapse the fieldset at the custom member levelfsHalfYear.Expanded = Falsem_xml = objPT.XMLDataobjPT = NothingCatch err As Exceptionm_xml = "<err>" & err.Source & " - " & err.Message & _"</err>"FinallyEnd TryReturn (m_xml)End Function
 
原创粉丝点击