回复 7楼 吹水佬
CLEAR
SET TALK OFF
SET SAFETY OFF
M_FILE=GETFILE("XLSX","电子表格")
cExcel = JUSTFNAME(M_File)
M_FILEPATH=ADDBS(JUSTPATH(M_file)) &&所打开文件所在的文件路径
DBF_FILE=SUBSTR(cexcel,1,LEN(cExcel)-4)
IF M_FILE=" "
=MESSAGEBOX("请输入待导入的电子子表格文件!",0+48,"提示")
RETURN
ELSE
IF JUSTEXT(M_FILE)#"XLS"
=MESSAGEBOX("你选择的不是EXCEL格式文档!",0+48,"提示")
RETURN
ENDIF
ENDIF
cHDR = "YES"
cSheet = "[sheet1$A:AB]"
cSQL = "SELECT * FROM " + cSheet
cConn = "Provider=Microsoft.ACE.OLEDB.12.0;"+"Extended Properties='Excel 12.0;HDR="+cHDR+";IMEX=1';"+ "Data Source=" + cExcel
** EXCEL2003及之前版本
** cConn = "Provider=Microsoft.Jet.OLEDB.4.0;"+ "Extended Properties='Excel 8.0;HDR="+cHDR+";IMEX=1';"+ "Data Source=" + cExcel
SET DEFAULT TO &M_FILEPATH
oConn = CREATEOBJECT("ADODB.Connection")
oConn.Open(cConn)
oRs = CREATEOBJECT("ADODB.Recordset")
oRs.Open(cSQL, oConn, 1, 3, 1)
oRs.MoveFirst
USE e:\gz\jj_stru
COPY STRUCTURE TO &M_FILEPATH\&DBF_FILE
USE &DBF_FILE IN 2
zap
cStr = oRs.GetString()
STRTOFILE(cStr, "tmp.txt")
SELECT 2
APPEND FROM tmp.txt DELIMITED WITH TAB
SELECT * FROM &DBF_FILE
oRs.Close
oConn.Close
CLOSE ALL
RETURN
以是是我的代码
附件是生成的txt文件,工号中出现了空值