Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Report Output To Excel.... Is this possible? If so best
Message
De
06/01/2001 21:54:09
 
 
À
06/01/2001 15:09:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Divers
Thread ID:
00459677
Message ID:
00460283
Vues:
20
>>Look at Application.DataToClip() to copy VFP table/cursor data to the
>>windows clipboard and then paste it into Excel. You are not constrained
>>to the 16K limit like COPY TO XLS. Another benefit to this
>>approach is that you can have a preformatted Excel spreadsheet template
>>and simply drop the data into it and save as another name. Here is an
>>example of that technique:
>>
>>oExcel = CREATEOBJECT('Excel.Application')
>>
>>*-- Open the preformatted Excel template file
>>oExcel.WorkBooks.Open(cExcelTemplateFile) && This is read only
>>
>>GO TOP IN vfp_cursor
>>*-- Copy tab delimited list of table values to windows clipboard
>>Application.DataToClip('vfp_cursor', RECCOUNT('vfp_cursor'), 3)
>>
>>WITH oExcel
>>*-- Select the proper sheet
>>.Sheets('sheetname').Select()
>>*-- Position the cursor
>>.Selection.Range("A6").Select()
>>*-- Paste the contents of the clipboard
>>.ActiveSheet.Paste()
>>
>>*-- Get rid of the table column names
>>.Rows("6:6").Select()
>>.Selection.ClearContents()
>>.Range("A1").Select()
>>
>>.DisplayAlerts = .F.
>>*-- Save file under a new name hence preserving the template for future use
>>.ActiveWorkBook.SaveAs(cDirAndFileName)
>>.Quit()
>>ENDWITH
>>
>>oExcel = .NULL.
>>RELEASE oExcel
>>
>
>Does the paste method still have problems dealing with .NULL. values? Is the paste method still limited in total size (used to be around 5K bytes???). I've not tried much pasting into Excel lately, so I'm not sure.

NULLs are still a problem but are correctable by doing an NVL() when selecting the data. There is a serious size and speed limit on the ClipBoard, but I'm not sure of the exact size; it's tied to available virtual memory space - I just stuff 3.5MB/45K recs in from VFP and pasted it into an Excel Spreadsheet (Win2K Pro SP1 256MB, VFP 6 SP4, Excel 2K SP1, jRandomOtherStuff running.) It took measurable time, but lots less than stuffing each cell one by one via automation would require.

>
>The NULL problem was a real bear, and the limited size could be dealt with in a loop. But the net result was *way* faster then trying to automate filling the cells of a sheet one by one, that's for sure.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform