locked
Pivot Table RRS feed

  • Question

  • I appreciate if anyone can help in this. I have this simple code to create a pivot table. It works fine excpet that the data does not come out under the Data Area. When the excel sheet is create, i have to right-click on DATA Column header, and select "move values to columns". This is the code:

    SET DEFAULT TO c:\temp

    oBook=GETOBJECT(CURDIR()+"Temp.XLS")

    WITH oBook
     oExcel=.Application
     .Application.Visible=.t.
     .windows[1].Activate()
     .Sheets[1].range("A1:F11").columns.autofit()

     lRowGrandTotals=.T.
     lColumnGrandTotal=.T.
     
     oSourceData=.sheets[1].Range("A1:F11")
     oDestination=.sheets[1].Range("H1")

     oPivotTable=.sheets[1].pivottablewizard(1,oSourceData,oDestination,"MyPivotTable",lRowGrandTotals,lColumnGrandTotal)

     oPivottable.AddFields("Account","Period","Type")

     xlRowField=1
     xlColumnField=2
     xlPageField=3
     xlDataField=4
     
     oPivottable.PivotFields["Account"].orientation=xlRowField
     oPivottable.PivotFields["Period"].orientation=xlColumnField
     oPivottable.PivotFields["Type"].orientation=xlPageField
     
     oPivottable.PivotFields["Debit"].Orientation =xlDataField
     oPivottable.PivotFields["Credit"].orientation=xlDataField

    ENDWITH

    • Moved by Wesley Yao Monday, November 9, 2009 5:26 AM vb question (From:Visual C++ Language)
    • Moved by Martin Xie - MSFT Wednesday, November 11, 2009 7:46 AM Redirect to appropriate forums for better responses. (From:Visual Basic Language)
    Thursday, November 5, 2009 12:24 PM

Answers

All replies