生活就好像一盒巧克力

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
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
// 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
posted on 2006-06-14 17:20  yiriqing  阅读(2608)  评论(0编辑  收藏  举报