OWC简介及其属性

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。
ChChartsChChart 对象集合
ChChartChartSpace 中的单个图表,一个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
// method
var iCallID = service.svcOLAP.callService
(onInitializePivotTableResult,
'InitializePivotTableXML',
strDataMember);
}
function onInitializePivotTableResult(result) {
// This function handles the InitializePivotTableXML()
// Web method result
text = result.value; // result string
// Evaluate return result
if (!result.error) {
// Assign the XML to the PivotList XMLData value
frm1.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 String
Dim m_XML As String
Dim strOLAPConn As String = _
ConfigurationSettings.AppSettings("OLAPConnectionString")
Try
Dim objPT As PivotTableClass = New PivotTableClass
objPT.ConnectionString = strOLAPConn
objPT.DataMember = strDataMember
m_XML = objPT.XMLData
objPT = Nothing
Catch err As Exception
m_XML = "<err>" & err.Source & " - " & err.Message & _
"</err>"
Finally
End Try
Return (m_XML)
End Function

Figure 10 LoadCustomPivotTableReport Web Method
<WebMethod()> Public Function LoadCustomPivotTableReport(ByVal _
strCity1 As String, ByVal strCity2 As String) As String
Dim m_XML As String
Dim strOLAPConn As String = _
ConfigurationSettings.AppSettings("OLAPConnectionString")
Dim objPT As PivotTableClass = New PivotTableClass
Dim objPTView As PivotView
Dim fldCity, fldName, fldProdFamily As PivotField
Dim fSetCustomers, fSetProduct As PivotFieldSet
Try
objPT.ConnectionString = strOLAPConn
objPT.DataMember = "Sales"
objPT.AllowFiltering = False
objPTView = objPT.ActiveView
objPTView.TitleBar.Caption = "City Comparison of Drink
Sales"
' Define the column elements
objPTView.ColumnAxis.InsertFieldSet(objPTView.FieldSets("Time"))
objPTView.ColumnAxis.FieldSets("Time").Fields("Year").Expanded = True
' Define the row elements
fSetCustomers = objPTView.FieldSets("Customers")
objPTView.RowAxis.InsertFieldSet(fSetCustomers)
fSetCustomers.Fields("Country").IsIncluded = False
fSetCustomers.Fields("State Province").IsIncluded = False
fSetCustomers.Fields("Name").IsIncluded = False
' Define the members of the row elements
fldCity = fSetCustomers.Fields("City")
fldCity.IncludedMembers = New Object() {strCity1, strCity2}
' Exclude all other field row members in the fieldset
fSetProduct = objPTView.FieldSets("Product")
objPTView.RowAxis.InsertFieldSet(fSetProduct)
fSetProduct.Fields("Product Department").IsIncluded = False
fSetProduct.Fields("Product Category").IsIncluded = False
fSetProduct.Fields("Product Subcategory").IsIncluded =False
fSetProduct.Fields("Brand Name").IsIncluded = False
fSetProduct.Fields("Product Name").IsIncluded = False
fldProdFamily = fSetProduct.Fields("Product Family")
fldProdFamily.IncludedMembers = "Drink"
' Define the measures
objPTView.DataAxis.InsertTotal(objPTView.Totals("Store Sales"))
objPTView.DataAxis.Totals("Store Sales").NumberFormat = _
"Currency"
' Return the XML data to the client side script
m_XML = objPT.XMLData
objPT = Nothing
Catch err As Exception
m_XML = "<err>" & err.Source & " - " & err.Message & "</err>"
Finally
End Try
Return (m_XML)
End Function

Figure 11 Load the XMLData for a Custom Report
function LoadSavedReport() {
// Purpose:  Call Web Service method to load the saved
// report
var iCallID = service.svcOLAP.callService(onLoadSavedReportResult,
'LoadSavedReport', 'OLAPReport1.xml');
}
function onLoadSavedReportResult(result) {
// Purpose: This function handles the
// wsOLAP.onLoadSavedReportResult() Web Service result
var text = result.value; // result string
// Evaluate return result
if (!result.error) {
// Assign the XML to the PivotList XMLData value
frm1.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 ptConstants
Set 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.value
End If
End Sub
</script>

Figure 13 Creating Custom Groups
<WebMethod()> Public Function ApplyCustomGrouping(ByVal _
strReportXMLData As String) As String
Dim m_xml As String
Dim objPT As PivotTableClass = New PivotTableClass
Dim objPTView As PivotView
Dim fsTime As PivotFieldSet
Dim fsHalfYear As PivotField
Try
objPT.XMLData = strReportXMLData
objPTView = 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 level
fsHalfYear.Expanded = False
m_xml = objPT.XMLData
objPT = Nothing
Catch err As Exception
m_xml = "<err>" & err.Source & " - " & err.Message & _
"</err>"
Finally
End Try
Return (m_xml)
End Function

转载于:https://www.cnblogs.com/yiriqing/archive/2006/06/14/425923.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值