EXCEL2007工作表已没有另存为DBF表的选项,当然也不能:oExcel.ActiveWorkbook.SaveAs('TEST.DBF',8)这种形式,
当然也不能用:appe from getfile("xls")这种形式,怎么办,不要跟我说退回到EXCEL2000,因为公司新的电脑都是按装EXCEL2007的,在EXCEL2007下如何操作EXCEL工作表成为DBF表,VFP真的好无奈啊,请各位高手支支招,谢谢!
------解决方案--------------------------------------------------------
假设你已经安装OFFICE2007:
oconnection = CREATEOBJECT("adodb.connection")
oconnection.connectionstring = 'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES;IMEX=1";
oconnection.open
oConnection.EXECUTE('SELECT * INTO [DBASE 5.0;DATABASE=R:\TEMP].AA FROM [SHEET1$]')
------解决方案--------------------------------------------------------
调用EXCEL程序,打开要导入的文件,循环单元格,填到对应的DBF文件的字段里
如:
oexl=CREATEOBJECT("excel.application")
oexl.workbooks.open("&lcDelimFile")
ncount=AFIELDS(aprtarray)
nrow=1
WAIT '正在执行所请求的操作,请稍候......' WINDOW AT 40,50 NOWAIT
DO WHILE .t.
APPEND BLANK
FOR i=1 TO ncount
cfield=aprtarray(i,1)
xhbl=oexl.cells(nrow,i).value
IF varTYPE(xhbl)="X" AND cfield="序号" THEN
MESSAGEBOX("第1列遇到空白记录!导入结束",64,"友情提示")
oexl.workbooks.close
oexl.quit
RETURN
ENDIF
REPLACE &cfield WITH xhbl
nrow=nrow+1
i=1
ENDDO
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------