A
aiHis
Unregistered / Unconfirmed
GUEST, unregistred user!
我在Excel中录制了如下宏:
怎么通过Delphi来调用!!!
等待!!!
With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExternal)
.Connection = _
"ODBC;DRIVER=SQL Server;SERVER=NHIS-CENTER;UID=sa;PWD=1;APP=Microsoft? Query;WSID=NHIS-CENTER;DATABASE=PJX"
.CommandType = xlCmdSql
.CommandText = Array( _
"SELECT mzfp.CZY, mzfp.KDKS, mzfp.ZXKS, Sum(mzfp.JE)" & Chr(13) & "" & Chr(10) & "FROM PJX.dbo.mzfp mzfp" & Chr(13) & "" & Chr(10) & "GROUP BY mzfp.CZY, mzfp.KDKS, mzfp.ZXKS" & Chr(13) & "" & Chr(10) & "ORDER BY mzfp.CZY, mzfp.KDKS, mzfp.ZXKS" _
)
.CreatePivotTable TableDestination:=Range("A1", TableName:="数据透视表1"
End With
ActiveSheet.PivotTables("数据透视表1".SmallGrid = False
ActiveSheet.PivotTables("数据透视表1".AddFields RowFields:=Array("KDKS", "ZXKS", _
ColumnFields:="CZY"
ActiveSheet.PivotTables("数据透视表1".PivotFields("Expr".Orientation = xlDataField
ActiveWindow.SelectedSheets.PrintPreview
若做过Excel数据透视表的同志最好能发个Email这些:lz_zzd@163.com,另外再加分。。。。
怎么通过Delphi来调用!!!
等待!!!
With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExternal)
.Connection = _
"ODBC;DRIVER=SQL Server;SERVER=NHIS-CENTER;UID=sa;PWD=1;APP=Microsoft? Query;WSID=NHIS-CENTER;DATABASE=PJX"
.CommandType = xlCmdSql
.CommandText = Array( _
"SELECT mzfp.CZY, mzfp.KDKS, mzfp.ZXKS, Sum(mzfp.JE)" & Chr(13) & "" & Chr(10) & "FROM PJX.dbo.mzfp mzfp" & Chr(13) & "" & Chr(10) & "GROUP BY mzfp.CZY, mzfp.KDKS, mzfp.ZXKS" & Chr(13) & "" & Chr(10) & "ORDER BY mzfp.CZY, mzfp.KDKS, mzfp.ZXKS" _
)
.CreatePivotTable TableDestination:=Range("A1", TableName:="数据透视表1"
End With
ActiveSheet.PivotTables("数据透视表1".SmallGrid = False
ActiveSheet.PivotTables("数据透视表1".AddFields RowFields:=Array("KDKS", "ZXKS", _
ColumnFields:="CZY"
ActiveSheet.PivotTables("数据透视表1".PivotFields("Expr".Orientation = xlDataField
ActiveWindow.SelectedSheets.PrintPreview
若做过Excel数据透视表的同志最好能发个Email这些:lz_zzd@163.com,另外再加分。。。。