这是一个手工录制的数据透视表的宏,想通过delphi 代码来操作EXCEL 达到执行该宏的效果.请问该如何写呢?Sub Macro1()
'    ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
        "'832006'!R1C1:R99C14").CreatePivotTable TableDestination:="", TableName:= _
        "数据透视表1", DefaultVersion:=xlPivotTableVersion10
    ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
    ActiveSheet.Cells(3, 1).Select
    ActiveWorkbook.ShowPivotTableFieldList = True
    With ActiveSheet.PivotTables("数据透视表1").PivotFields("公司")
        .Orientation = xlRowField
        .Position = 1
    End With
    With ActiveSheet.PivotTables("数据透视表1").PivotFields("代码")
        .Orientation = xlRowField
        .Position = 2
    End With
    With ActiveSheet.PivotTables("数据透视表1").PivotFields("名称")
        .Orientation = xlRowField
        .Position = 3
    End With
    With ActiveSheet.PivotTables("数据透视表1").PivotFields("类型")
        .Orientation = xlColumnField
        .Position = 1
    End With
    With ActiveSheet.PivotTables("数据透视表1").PivotFields("舱位编码")
        .Orientation = xlColumnField
        .Position = 2
    End With
    ActiveSheet.PivotTables("数据透视表1").AddDataField ActiveSheet.PivotTables("数据透视表1" _
        ).PivotFields("金额"), "求和项:金额", xlSum
    ActiveSheet.PivotTables("数据透视表1").AddDataField ActiveSheet.PivotTables("数据透视表1" _
        ).PivotFields("费用"), "求和项:费用", xlSum
End Sub