Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Spreadsheet update
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00317983
Message ID:
00318174
Vues:
21
I have successfully automated transactions between Excel and VFP, such as reading cells from Excel and writing back new data to other cells. Try something like this, although this particular code snippet is not tested:
oExcel = CREATEOBJECT('excel.application')
oExcel.Workbooks.Open("[FILENAME]")	
oExcel.Visible = .T.  && to see the show.

FOR lnRow = 1 TO [LAST ROW]

  lcCell = 'A' + LTRIM(STR(lnRow))
  oExcel.Range('&lcCell.').Select
  lcSSN = oExcel.ActiveCell.FormulaR1C1

  [Look up Earnings]

  oExcel.Cells(lnRow, 2) = lnEarnings

ENDFOR
This will start Excel as a data server and open a spreadsheet. It starts at the the first row in a column and reads in the SSN. Then, use VFP to look up the earnings. Next, it will send the earnings to the column immediately to the right of the SSN. Then, it will go on to the next row.

After running this, you will need to save the file to where you want and then release the oExcel object, to close the connection.

Good Luck!!

Michael Reynolds


>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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform