General information
Category:
Reports & Report designer
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
>>>In this months FoxPro Advisor there is an article for sending memo files to an Excel Spreadsheet. That got me thinking....
>
>>Hi Della,
>
>COPY to only works for less that 16384 (2^14) for whatever reason.
>Do you have any good ways to get data into EXCEL easily and quickly??
>
>
>Peter
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only