????? ??????? PivotTable Office Web Component ?? VB

?????? ????????? ?????? ?????????
???? ???????: 235542 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ????? ??????? PivotTable Office "???? ???" ???? ??????? ??? ????? Visual Basic.

??????? ????

?????? ??? ?? Office ?? ?????? ?? ????? ?????? ???? ????? ?? ??????? ???????? Office. ??? "?????? ???" ?? ????? ??????, ????? ????? ?? ????? Visual Basic ?? ????? ?????? ???? ????????.

????? ????? ???????

  1. ?? ?????? Visual Basic ?? ????? ????? ???? EXE ??????. ??? ????? Form1 ???? ???????.
  2. ??? Project|References ????? ???? ??? ????? 2.1 ?????? ?????? ActiveX Microsoft ?? ???? ??? ?????.
  3. ???? ?????? CTRL + T ???? ???? ?????? ????? ??????. ????? Microsoft Office Web Components ?? ???? ??? ?????.

    ??????: ????? Office XP ??? ?? ?? Office 2000 ? Office XP ??? ????????. ???????? Office 2003 Web Components ????? Microsoft Office Web 11.0 ?????? ?????. ???????? ?????? ??? ?? Office 2000 ????? ????? 9.0 ??? ?????? ?? Microsoft Office. ???????? Office XP ??? ????????? ????? ????? 10.0 ??? ?????? ?? Microsoft Office.
  4. ????? PivotTable ??? ???????.
  5. ?? ???? ????????? ???????? ?? Form1 ????? ???????? ???????? ???????:
    Option Explicit
    
    Dim cnnConnection As Object
    
    Private Sub Form_Load()
    
       Dim strProvider As String
       Dim view As PivotView
       Dim fsets As PivotFieldSets
       Dim c As Object
       Dim newtotal As PivotTotal
       
       strProvider = "Microsoft.Jet.OLEDB.4.0"
       ' Create an ADO object
       Set cnnConnection = CreateObject("ADODB.Connection")
       ' Set the provider and open the connection to the database
       cnnConnection.Provider = strProvider
       cnnConnection.Open "C:\pivottest.mdb"
       ' Set the pivot table's connection string to the cnnConnection's connection string
       PivotTable1.ConnectionString = cnnConnection.ConnectionString
       ' SQL statement to get everything from table1
       PivotTable1.CommandText = "Select * from table1"
       
       ' Get variables from the pivot table
       Set view = PivotTable1.ActiveView
       Set fsets = PivotTable1.ActiveView.FieldSets
       Set c = PivotTable1.Constants
       
       ' Add Category to the Row axis and Item to the Column axis
       view.RowAxis.InsertFieldSet fsets("Category")
       view.ColumnAxis.InsertFieldSet fsets("Item")
       
       ' Add a new total - Sum of Price
       Set newtotal = view.AddTotal("Sum of Price", view.FieldSets("Price").Fields(0), c.plFunctionSum)
       view.DataAxis.InsertTotal newtotal
       view.DataAxis.InsertFieldSet view.FieldSets("Price")
          
       ' Set some visual properties
       PivotTable1.DisplayExpandIndicator = False
       PivotTable1.DisplayFieldList = False
       PivotTable1.AllowDetails = False
    End Sub
    
    Private Sub Form_Terminate()
      ' Remove reference to the ADO object
      Set cnnConnection = Nothing
    End Sub
    
    
    Private Sub PivotTable1_DblClick()
       Dim sel As Object
       Dim pivotagg As PivotAggregate
       Dim sTotal As String
       Dim sColName As String
       Dim sRowName As String
    
       Dim sMsg As String
       
       ' Get the selection object you double-clicked on
       Set sel = PivotTable1.Selection
       ' If it is a aggregate, you can find information about it
       If TypeName(sel) = "PivotAggregates" Then
          ' Select the first item
    
          Set pivotagg = sel.Item(0)
          ' Display the value
          MsgBox "The cell you double-clicked has a value of '" & pivotagg.Value & "'.", vbInformation, "Value of Cell"
          
          ' Get variables from the cell
          sTotal = pivotagg.Total.Caption
          sColName = pivotagg.Cell.ColumnMember.Caption
          sRowName = pivotagg.Cell.RowMember.Caption
          
          ' Display the row and column name
          sMsg = "The value is " & sTotal & " by " & sRowName & " by " & sColName
          MsgBox sMsg, vbInformation, "Value Info"
       End If
    End Sub
    					
  6. ??? ???? ????? ????? ????? ?????? ????? ???????? Microsoft Access. ???? ????? Access ?? ???? ????? ?????? Access ?????. ?? ???? ????? ???? c:\pivottest.mdb. ???? ????? ??????? ??? ????? ???? ?? Design View. ???? ???????? ???????:

    ?? ??? ??????????? ??? ??????
    ??? ???????? ????????
    ??????????
    ?????????
    ????????
  7. ???? ?????? ?? ???? ????????? ????1. ??? "??" ?????? ?????. ???? ????? ??????? ??? ????1 ?? ???? ???????? ???????:

    ?? ??? ??????????? ??? ??????
    ????????????????
    ???????????????5
    shirt???????23
    hammer???????16
    ??????????????5
    pants???????31
    drinks??????2
  8. ????? Access ???? ?????.
  9. ???? ??????? F5 ?????? ???????. ??? ????? ? ??? ??? ?????? ???????. ???? ????? ??????? ??? ???? ????? ?? ???????? ???? ???? ?????? ? ?????? ????? ?????? ????????.

?????

?????? ??? ???? ?? ????????? ??? Office ??????? ?????? ???? ??? Microsoft Office ????? ??:
http://support.microsoft.com/ofd

???????

???? ???????: 235542 - ????? ??? ??????: 01/????/1427 - ??????: 3.5
????? ???
  • Microsoft Office PivotTable Component 9.0
  • Microsoft Office XP Web Components
  • Microsoft Office 2003 Web Components
????? ??????: 
kbmt kbautomation kbhowto kbweb KB235542 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????235542

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com