iFix中如何实现EXCEL报表在VBA中引用MicrosoftExcel11.0ObjectLibrary和MicrosoftADO6.0Library。在画面中添加个按钮。复制以下代码:‘----------开始复制(不包括此行)--------------[hide]OptionExplicitDimrsADOAsADODB.RecordsetDimcnADOAsADODB.ConnectionPrivateSubCommand1_Click()DimStrDirAsStringStrDir=E:\DimiAsLongDimSqlAsStringSql=SELECT*FROMTHISNODESetcnADO=NewADODB.ConnectionSetrsADO=NewADODB.RecordsetcnADO.ConnectionString=Provider=MicrosoftOLEDBProviderforODBCDrivers;DSN=FIXDynamicsRealTimeData;UID=;PWD=cnADO.OpenrsADO.CursorLocation=adUseClientrsADO.OpenSql,cnADO,adOpenDynamic,adLockUnspecified,-1IfrsADO.RecordCount=0ThenMsgBox无数据!,vbOKOnly+vbInformation,信息...SetcnADO=NothingSetrsADO=NothingExitSubEndIfDimxlAppAsObjectDimxlBookAsObjectDimxlSheetAsObjectSetxlApp=NewExcel.ApplicationxlApp.DisplayAlerts=FalsexlApp.Visible=FalseSetxlBook=xlApp.Workbooks.Open(StrDir&\报表.xls)'需要文件(E:\报表.xls)SetxlSheet=xlBook.Worksheets(1)Fori=1TorsADO.RecordCountxlSheet.Cells(i,1)=rsADO.Fields(1).Value&xlSheet.Cells(i,2)=rsADO.Fields(2).Value&xlSheet.Cells(i,3)=rsADO.Fields(3).Value&xlSheet.Cells(i,4)=rsADO.Fields(4).Value&NextixlApp.Visible=TruexlApp.DisplayAlerts=FalseSetxlSheet=NothingSetxlBook=NothingSetxlApp=NothingSetcnADO=NothingSetrsADO=NothingEndSub[/hide]‘----------结束复制(不包括次行)--------------注意:1.iFix历史数据库只支持读90天的数据,在SQL语句中限定时间即可。2.也可以读取其他数据源的数据,如ACCESS、SQLSERVER等,只要改一下ConnectionString。