Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Importing from Excel into Memo Fields
Message
De
03/10/2000 08:16:19
 
 
À
02/10/2000 20:47:03
Gavin Reid
L & M Marketing Pty Ltd
Frenchs Forest, Australie
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00423847
Message ID:
00423957
Vues:
16
Gavin,

The following code should work. However, this is *much* slower than APPEND FROM.
Hope this helps.
Daniel
LOCAL loXls, loWorkbook, loSheet, lnFields, lnRow, llEofXls, i

loXls      = CREATEOBJECT("excel.application")
loWorkbook = loXLS.Application.Workbooks.Open("c:\temp\bidon.xls")
loSheet    = loXls.worksheets("Sheet1") 

lnFields   = 4 && number of columns in spreadsheet

DIMENSION laRecord[lnFields]

*-- create cursor/table according spreadsheet structure
CREATE CURSOR Test (Field1 C(15), mMemo M, Field2 C(15), Field3 C(15))

lnRow = 2

DO WHILE NOT llEofXls
	
	*-- store each cell of current row into an array
	FOR i = 1 TO lnFields
		laRecord[i] = loSheet.Range(loSheet.Cells(lnRow, i), loSheet.Cells(lnRow, i)).value
	ENDFOR &&* i = 1 TO lnFields
	
	IF EMPTY(laRecord[1])
		*-- we bail out if we hit an empty cell in column 1
		llEofXls = .t.
	ELSE
		*-- add the record to the cursor
		INSERT INTO Test FROM ARRAY laRecord
	ENDIF

	lnRow = lnRow + 1
	
ENDDO
Another way that I thought of to import the data was to use OLE to open the Spreadsheet and loop through the Cells and insert them into the DBF. Does anyone know how to read an Spreadsheet using OLE, I know how to create one using OLE but not how to do the reverse. I don't really want to use low level file functions either <s>. >>
Daniel
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform