| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1855 人关注过本帖
标题:Excel导入VFP报错
只看楼主 加入收藏
manto10
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2020-3-10
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:2 
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
sxy166
Rank: 3Rank: 3
等 级:论坛游侠
威 望:6
帖 子:69
专家分:127
注 册:2012-3-28
收藏
得分:14 
if endif 判断语句不能在窗口执行
2020-03-10 10:29
manto10
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2020-3-10
收藏
得分:0 
@sxy166 谢谢老师!
2020-03-10 14:36
快速回复:Excel导入VFP报错
数据加载中...
 
   



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

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