Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Automate Excel with Visual foxpro 9 (help)

Automate Excel with Visual foxpro 9 (help)

Automate Excel with Visual foxpro 9 (help)

Hi all,

I'm in the process of learning how to export information to excel but came across an issue that I can seem to resolve.

I have a table ("Testtable") with 4 records (4 rows and 5 columns) see image below
[img https://ibb.co/jhrVd5]

In VFP9 im running this code;

CODE --> 9

local oExcel, oSheet
oExcel = CreateObject("Excel.Application")
oExcel.Visible = -1   && for debugging
oSheet = oExcel.ActiveSheet
oSheet.cells(1,1).Value = "Name of Company"
oSheet.cells(2,1).Value = orderdate
oSheet.Cells(2,2).Value = line
oSheet.Cells(2,3).Value = item
oSheet.Cells(2,4).Value = customer_number 

The code above opens up Excel with the following data on it;

The code i'm using only grabs what's stored in row 1 on the table. I can't figure out how to get the rest of the data to excel. Im using this approach because I need add format the excel with more data like Name of the company, address, phone number etc..

Any help/suggestions will be greatly appreciated.
Thank you

RE: Automate Excel with Visual foxpro 9 (help)

Of course this only pulls over one row. Execel Cell Value is just one Value each, not a controlsource, even less a "columnsource", if there would be such a thing.

Either you do a SCAN..ENDSCAN and fill every cell of every row and column, or you EXPORT TYPE XLS or COPY TO TYPE XLS and postprocess the resulting excel file in terms of the caption row 1.

Bye, Olaf.

RE: Automate Excel with Visual foxpro 9 (help)

Of Olaf's choices, doing COPY TO and then post-processing is almost certainly much faster. If you're only dealing with a few records, it doesn't matter, but if you have hundreds or thousands, you'll see the difference.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close