回复 楼主 laibinhua
试试用SPTEXCEL表
DBF表
** EXCEL2003及之前
** Driver={Microsoft Excel Driver (*.xls)};
** EXCEL2007及之后
** Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};
CREATE CURSOR tt (f1 C(50),f2 C(50),f3 C(50),f4 I,f5 N(10,2),f6 N(12,2))
cFile = "C:\TEMP\导出excel\导出excel.xls"
cDSN = "Driver={Microsoft Excel Driver (*.xls)};";
+ "DBQ=" + cFile + ";"
hDSN = SQLSTRINGCONNECT(cDSN)
IF hDSN <= 0
MESSAGEBOX("访问 "+cFile+" 文件失败")
RETURN
ENDIF
**cSheet = "Sheet1$A1:F65500" && 选择区域
cSheet = "Sheet1$"
cSQL = "SELECT ";
+ "IIF(ISNULL(品名),'',品名) as f1,";
+ "IIF(ISNULL(规格),'',规格) as f2,";
+ "IIF(ISNULL(单位),'',单位) as f3,";
+ "IIF(ISNULL(数量),0, 数量) as f4,";
+ "IIF(ISNULL(单价),0, 单价) as f5,";
+ "IIF(ISNULL(金额),0, 金额) as f6 ";
+ "FROM [" + cSheet + "]"
IF SQLEXEC(hDSN, cSQL, "tmp") > 0
SELECT tt
APPEND FROM DBF("tmp")
SELECT * FROM tt
USE IN "tmp"
ELSE
MESSAGEBOX("查询 "+cFile+" 文件数据失败")
ENDIF
SQLDISCONNECT(hDSN)
RETURN