Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Re: Excel
Miscellaneous
Thread ID:
00060557
Message ID:
00061149
Views:
36
>I have a query whose results I currently send to an Excel
>spreadsheet. Id like to give the users the spreadsheet from
>inside the exe...I can creat a form with an embedded sheet
>easily enough, but how do I order it to read the results
>in?

*****
* The following will open an Excel OLE object, load a template spreadsheet,
* populate the spreadsheet with data from a Fox table and save/print/(other command)
* the spreadsheet
*****

oXLS = createobject("Excel.application")

SELECT * FROM dataTable INTO CURSOR Tmp
SELECT Tmp

oXLS.Workbooks.Open("Template.XLS")
oXLS.Sheets(1).Activate
oXLS.Cells(6,5).Value = 'Title or Variable value'

*****
* Start of data area in spreadsheet
*****
lnRow = 13
SCAN WHILE !EOF()
oXLS.Cells(lnRow,2).Value = Tmp.Name
oXLS.Cells(lnRow,3).Value = Tmp.Social
oXLS.Cells(lnRow,5).Value = Tmp.ReviewDate
oXLS.Cells(lnRow,6).Value = Tmp.Rating
oXLS.Cells(lnRow,7).Value = Tmp.AnnSalary
lnRow = lnRow + 1
ENDSCAN

oXLS.ActiveWorkBook.SaveAs(lcFile, 39 ) && 39=Excel 5 format, 33=Excel 4 format
oXLS.ActiveWorkBook.Close(0)
oXLS.Quit
RELEASE oXLS

RETURN
Mike Kelly
Venture Catalyst Group, Inc.
http://www.vcatgroup.com
Previous
Reply
Map
View

Click here to load this message in the networking platform