****************************************
* vfp打开excel文件 **************************************** objExcel=createobject("excel.application")
objExcel.workbooks.open(filename2)
objExcel.visible=.t.
release objExcel
**************************************** **************************************** * vfp用代码读取xls的指定单元格,存入数据库中 ****************************************
use tabxls1 objExcel=createobject("excel.application")
objExcel.workbooks.open(filename1)
objExcel.worksheets(1).activate
cntRow=objExcel.sheets(1).usedrange.rows.count
FOR I=1 TO CNTROW
wait windows ALLTRIM(str(100*I/CNTROW,4,1)) nowait
xlsval(1)=i
FOR j=1 TO 10
tmpval=objExcel.cells(i,j).value
tmpval=IIF(VARTYPE(tmpval)='X','',tmpval)
tmpval=IIF(VARTYPE(tmpval)='N',ALLTRIM(STR(tmpval,80)),tmpval)
tmpval=IIF(VARTYPE(tmpval)='L','',tmpval)
tmpval=IIF(VARTYPE(tmpval)='U','',tmpval)
xlsval(j+1)=tmpval
ENDFOR
SELECT tabxls1
APPEND BLANK
GATHER FROM xlsval
STORE '' TO xlsval
ENDFOR
* objExcel.activeworkbook.saved=.t.
objExcel.workbooks.close
release objExcel **************************************** **************************************** **************************************** |
|
来自: Alkaid2015 > 《75.VFP狐仙◆》