>I need to generate a report from VFP and save that report to a excel format files. How can I do this?Linda:
As has been said in this thread, you can use
COPY TO ... XLS
from the cursor or table that contains your report data. This is fast enough but has a couple of problems:
- It creates an older format of Excel. That is solved by opening the file in Excel and saving it with a newer XLS format.
- It has a limitation of 16535 rows.
If you have more rows that that there are other ways to do it.
You could use COM Automation (as Hilmar pointer out), to open and manipulate the file directly in Excel programmatically. You could send each row to Excel independently. This gives you excellent control but it's slow.
You could save the data to a txt or csv file and load it into Excel. Much faster but beware that Excel will understand only the first 15 digits of a numeric field and replace the rest with zeroes. So if you have something like account numbers as numeric (as some people do), you can get into problems. There are ways around this too as always <g>.
Hope this gets you started.
Check:
"Microsoft Office Automation with Visual FoxPro" by Tamar E. Granor and Della Martin
http://www.hentzenwerke.com/catalogavailability/autofox.htmand examples in the Wiki:
http://fox.wikis.com/wc.dll?Wiki~AutomationExamples~VFP