Using this code:
I kept getting lnCnt=41 when executing in the program. If I stepped through, lnCnt=78.
I Added this after the IMPORT line:
And now it works right.
So, IMPORT seems to be an asynchronous. I don't like the idea of the 200ms delay being potentially too short... anyone have any ideas?
(As I type this, I thought of a loop that repeatedly trys to lock the .XLS file being imported, using FOPEN, but it's possible that VFP closes the XLS file before finishing adding to the new DBF...)
Alternatives I'd rather avoid are:
1) using automation to access the spreadsheet (it's just plain slow)
2) pre-creating a DBF and somehow appending from the spreadsheet... that would require me to know the format of the spreadsheet, and I want to be more general than that.
3) ODBC to Excel... too messy
- Bill
Get the best answers to your questions -- See FAQ481-4875.
Code:
IMPORT from (tcFile) TYPE XL5 SHEET (lcAlias)
lnFlds = AFIELDS(laFlds)
SELECT (lcAlias)
GOTO TOP
COUNT TO lnCnt
I kept getting lnCnt=41 when executing in the program. If I stepped through, lnCnt=78.
I Added this after the IMPORT line:
Code:
DECLARE Sleep IN Win32Api AS apiSleep LONG dwMilliseconds
apiSleep( 200 )
And now it works right.
So, IMPORT seems to be an asynchronous. I don't like the idea of the 200ms delay being potentially too short... anyone have any ideas?
(As I type this, I thought of a loop that repeatedly trys to lock the .XLS file being imported, using FOPEN, but it's possible that VFP closes the XLS file before finishing adding to the new DBF...)
Alternatives I'd rather avoid are:
1) using automation to access the spreadsheet (it's just plain slow)
2) pre-creating a DBF and somehow appending from the spreadsheet... that would require me to know the format of the spreadsheet, and I want to be more general than that.
3) ODBC to Excel... too messy
- Bill
Get the best answers to your questions -- See FAQ481-4875.