Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Spreadsheet update
Message
 
À
13/01/2000 17:59:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00317983
Message ID:
00318898
Vues:
34
Hello Chris...

You can use OLE automation with Excel as an object created in VFP...

oExcel = CreateObject("Excel.Application") && Creates oExcel as an object ref. to Excel in VFP.
lsFile = GetFile(...) && Identify the workbook you want.
oExcel.Workbooks.Open(lsFile) && Use the Open method of the Workbooks object to open the file you want.
oSheet = oExcel.ActiveWorkBook.ActiveSheet && Object ref. to the actual worksheet you want (assuming it's the topmost one).

For j = 1 To .... && Loop to read values (assume they are in column "G")...
lsCmd = [lvVal = oSheet.Range("G] + ;
Alltrim(Str(j, 4, 0)) + [").Value] && Build cmd. string: lvVal = oSheet.Range("G5").Value, for example.
&lsCmd && Execute the cmd: the desired Excel value is now in lvVal.
laData[i, j] = lvVal && Do something with lvVal (store in an array, for example)
Next j && On to next one.

oExcel.WorkBooks.Close() && Close Excel...
oExcel.Quit()
Release oSheet
oExcel = .Null. (Or release oExcel, it's up to you...)

When you fire up Excel in this way, you cannot actually see it as an application. If you want to see it (and for debugging purposes, you probably will), you can say: oExcel.Visible = .T. and it will become visible in the normal way.

The Excel object model is (to me!) very complicated, but I have had some success with the above methodology. There may be better ways to do this, and if you find one, I'd love to know about it.

Good Luck, ~ David Bailey ~

>I have a large, very wide spreadsheet in ecxel that has employee social security number in one column and one blank column for earnings figures. The spreadsheet cannot easily be exported to a table because of its complexity.
>
>
>I have a VFP table with the ss# and the earnings figures. Is there some way to have vfp access the spreadsheet, locate the ss# and write the earnings in the adjacent column? I cant fathom having to do this by hand.
>
>
>TIA
>Chris
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform