Figure 3 Office Web Components (version 10)
Figure 4 PivotTable and Chart-related Objects
Figure 5 PivotTable Component's Programmatic Interface
Figure 6 Chart Component's Programmatic Interface
Figure 8 Connecting to an OLAP Data Source function initializePivotTable(strDataMember) { // This function calls the InitializePivotTableXML() Web // method var iCallID = rvice.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 (!) { // Assign the XML to the PivotList XMLData value frm1.PivotTable1.XMLData = text; } el { alert("Unhandled error - " + de + " " + Detail.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 = Fal objPTView = objPT.ActiveView objPTView.TitleBar.Caption = "City Comparison of Drink Sales" ' Define the column elements objPTView.ColumnAxis.InrtFieldSet(objPTView.FieldSets("Time")) objPTView.ColumnAxis.FieldSets("Time").Fields("Year").Expanded = True ' Define the row elements fSetCustomers = objPTView.FieldSets("Customers") objPTView.RowAxis.InrtFieldSet(fSetCustomers) fSetCustomers.Fields("Country").IsIncluded = Fal fSetCustomers.Fields("State Province").IsIncluded = Fal fSetCustomers.Fields("Name").IsIncluded = Fal ' 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 fieldt fSetProduct = objPTView.FieldSets("Product") objPTView.RowAxis.InrtFieldSet(fSetProduct) fSetProduct.Fields("Product Department").IsIncluded = Fal fSetProduct.Fields("Product Category").IsIncluded = Fal fSetProduct.Fields("Product Subcategory").IsIncluded =Fal fSetProduct.Fields("Brand Name").IsIncluded = Fal fSetProduct.Fields("Product Name").IsIncluded = Fal fldProdFamily = fSetProduct.Fields("Product Family") fldProdFamily.IncludedMembers = "Drink" ' Define the measures objPTView.DataAxis.InrtTotal(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() { // Purpo: Call Web Service method to load the saved // report var iCallID = rvice.svcOLAP.callService(onLoadSavedReportResult, 'LoadSavedReport', 'l'); } function onLoadSavedReportResult(result) { // Purpo: This function handles the // LoadSavedReportResult() Web Service result var text = result.value; // result string // Evaluate return result if (!) {墙纸品牌十大排名 // 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 e 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 t. fsTime = objPTView.FieldSets("Time") ' Add a custom group field named "Group1" to the Time field ' t. fsHalfYear = fsTime.AddCustomGroupField("CustomGroup1", _ "CustomGroup1", "Quarter") 我有一个秘密作文' Add a custom field t 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 fieldt member to include all "Q3" ' and "Q4" members under 1997. fsHalfYear.AddCustomGroupMember _ (fsTime.Member.ChildMembers("1997").Name, _ New Object() {"Q3", "Q4"}, "2ndHalf") ' Collap the fieldt at the custom member level fsHalfYear.Expanded = Fal 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
本文发布于:2023-07-20 20:09:22,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/fan/82/1107556.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |