结合类中操作excel的一些代码和十豆三老师的VFP全面控制EXCEL自行解决了,
http://xitong.
不考虑一些特殊的情况发生,速度快了很多
下面是代码:
SELECT * FROM 表1 INTO CURSOR tmp
_vfp.DataToClip("tmp",,3)
****************************
oExcelApp=CREATEOBJECT('Excel.Application')
&&Excel對象建立
With oExcelApp
.Workbooks.Add
&&添加新工作簿
.Workbooks(1).ACTIVATE
.sheets(1).Select
.ActiveSheet.Paste
&&粘贴
ENDWITH
LOCAL cExcelFile,cEXD as String
IF oExcelApp.version>="12.0" THEN
cExd= "XLSX"
ELSE
cExd= "XLS"
ENDIF
LOCAL
FileRate
FileRate=CHRTRAN(TRANSFORM(DATETIME()),' :-.','')
LcCaption=ALLT(_screen.ActiveForm.CAPTION)
cExcelFile=LcCaption+'_'+TRAN(FileRate)+ "." + cExd
DO WHILE FILE(cExcelFile)
cExcelFile=LcCaption+'_'+TRAN(FileRate)+ "." + cExd
FileRate=CHRTRAN(TRANSFORM(DATETIME()),' :-.','')
IF FILE(cExcelFile)
LOOP
ELSE
EXIT
ENDIF
ENDDO
cExcelFile=PUTFILE('文件保存為(&N):',cExcelFile,cExd)
oExcelApp.ActiveWorkbook.SaveAs('&cExcelFile',39)
MESSAGEBOX("导出成功!",64,"提示")
oExcelApp.Visible=.T.
oExcelApp.Quit
RELEASE oExcelApp
*************
以下是复制在剪贴板的单条选中记录,不用全表复制
PUBLIC aa
SELECT 表1
aa = RECNO()
SELECT * FROM 表1 WHERE RECNO()=aa INTO CURSOR tmp
_vfp.DataToClip("tmp",,3)
[此贴子已经被作者于2017-1-23 15:39编辑过]