Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Convert
Message
 
À
15/08/2005 06:56:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 8
Database:
Visual FoxPro
Divers
Thread ID:
01040893
Message ID:
01040902
Vues:
17
>hi,
>OK. my Workbook have just one sheet .
>>>hi all,
>>>
>>>would you help me.
>>>to convert my excell sheet to vfp.table
>>>
>>>as
>>>1.getfile() &&choice any excell sheet
>>>
>>>2. convert this sheet to vfp.table
>>>
>>>thanks
>>
>>You can't use GETFILE() to receive the Sheets contained in Excel Workbook. You can use it to get the Excel Workbook only.

The easiest way is:
LOCAL lcExcelFile
lcExcelFile = GETFILE("XLS")
IF NOT EMPTY(lcExcelFile)
   IMPORT FROM (lcExcelFile) XL5  && You can include SHEET TheNameOfTheSheet here
   USE (lcExcelFile) IN 0
   BROWSE NORMAL
ENDIF
BUT you must know what column what information contains. I mean this way you can get a DBF that have fields like:
A B C ... and you must know What data "A" field have.

Other way is to use automation, but you must have Excel installed in all computers that your application will run:
LOCAL lcExcelFile, loExcel
lcExcelFile = GETFILE("XLS")
IF NOT EMPTY(lcExcelFile)
   loExcel = CREATOBJECT("Excel.Application")
   loExcel.Open(lcExcelFile)
   CREATE CURSOR MyExcel (.........) && Field List of the cursor you want to import
   WITH loExcel.ActiveWorkBook
        FOR nRow = 1 TO .Rows.Count
            APPEND BLANK IN MyExcel
            FOR nCol = 1 TO .Columns.Count
                lcField = FIELDS(nCol)
                REPLACE (lcField) WITH .Cells(nRow, nCol).Value  && With proper transformations if you needed one
            NEXT
        NEXT
   ENDWITH
ENDIF
Keep in mind that the Automation section here is not tested and I didn't put any error handling.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform