*!* 从某个大的 Xlsx 文件提取数据的压力测试:
*!* 测试结果:某个 Xlsx 文件有116,000行,12M,SQL 耗时5秒,DBF = 32MB
Clear
Set Talk Off
Local lcXLBook As String, lnSQLHand As Integer, ;
lcSQLCmd As String, lnSuccess As Integer, ;
lcConnstr As String
Clear
lcXLBook = Getfile("xlsx")
lnSec = Seconds( )
lcConnstr = [Driver=] + ;
[{Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};] + ;
[DBQ=] + lcXLBook
If !File( lcXLBook )
? [Excel 文件没找到]
Return .F.
Endif
lnSQLHand = SqlStringConnect( lcConnstr )
lcSQLCmd = [Select * From "Sheet$"] && Sheet Name in Excel
lnSuccess = SQLExec( lnSQLHand, lcSQLCmd, [xlResults] )
? [SQL 命令状态:], Iif( lnSuccess > 0, '成功!', '失败!' )
If lnSuccess < 0
Local Array laErr[1]
Aerror( laErr )
? laErr(3)
SQLDisconnect( lnSQLHand )
Return .F.
Endif
? "耗时:" + TRANSFORM( Seconds( ) - lnSec )
Select xlResults
Browse Normal
SQLDisconnect( lnSQLHand )
团队红星二锅头,队长王猛,领队李冲,顾问杨伟,副队张挺,外联马彪,内勤韩秀,人事顾闯,财务赵魁,后勤周强