标题:Excel导入VFP报错
取消只看楼主
manto10
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2020-3-10
结帖率:100%
已结贴  问题点数:20 回复次数:1 
Excel导入VFP报错
LOCAL lcXLBook AS STRING, lnSQLHand AS INTEGER, ;
    lcSQLCmd AS STRING, lnSuccess AS INTEGER, ;
    lcConnstr AS STRING
CLEAR

lcXLBook = [C:\SampleWorkbook.xlsx]

lcConnstr = [Driver=] + ;
    [{Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};] + ;
    [DBQ=] + lcXLBook

IF !FILE( lcXLBook )
    ? [Excel file not found]
    RETURN .F.
ENDIF
*-- Attempt a connection to the .XLSX WorkBook.
*-- NOTE: If the specified workbook is not found,
*-- it will be created by this driver! You cannot rely on a
*-- connection failure - it will never fail. Ergo, success
*-- is not checked here. Used FILE() instead.
lnSQLHand = SQLSTRINGCONNECT( lcConnstr )

*-- Connect successful if we are here. Extract data...
lcSQLCmd = [Select * FROM "Sheet1$"]
lnSuccess = SQLEXEC( lnSQLHand, lcSQLCmd, [xlResults] )
? [SQL Cmd Success:], IIF( lnSuccess > 0, 'Good!', 'Failed' )
IF lnSuccess < 0
    LOCAL ARRAY laErr[1]
    AERROR( laErr )
    ? laErr(3)
    SQLDISCONNECT( lnSQLHand )
    RETURN .F.
ENDIF
搜索更多相关主题的帖子: not Driver IF Excel STRING 
2020-03-10 09:45
manto10
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2020-3-10
得分:0 
@sxy166 谢谢老师!
2020-03-10 14:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-499678-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013898 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved