Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Populate excel sheet
Message
From
26/05/2006 10:09:46
 
 
To
26/05/2006 06:43:19
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01125196
Message ID:
01125263
Views:
13
>I need to populate existing predefined excel file with some values from VFP. Excel file has 3 sheet (for examle sheet1, sheet2, sheet3). How to populate cells in excel file on specific sheet (1, 2 or 3)
>
>oExcel = CreateObject("Excel.Application")
>
>and ???
>
>Thanks in advance.

Have look at Rep2Excel here on UT (Download#14800).
It is class full of wrapper methods for doing common excel tasks.
So instead of directly talking to excel object (and having to know all that object hierarchy constats etc) you instantiate class object
local oXl
oXl=createobject('Excel_file_automation')
oXl.open_instance(cYourExcelTemplate)
And then you write content using simpe method calls
addressing entire file via simple 2 or 3D positioning
(nRow,nColumn)
(nSheet,nRow,nColumn)

This simplifies things quiet a bit and saves you kilometers
of coding those nasty excel code blocks.

You get to write stuff as easy as ;
oXl.make_cell( 1  , 3  , 5  , 'HelloWorld') 

oXl.write_array(1  , 4  , 5  , @myArray ) 
oXl.write_table(2  , 1  , 1  , myAlias ,'field1|field2|...' ) 
.
oXl.paint_box(1,1 , 22,50 , nColor)
.
.
.
*and then simply issue
oXl.save_to(cYourTargetFile)
There are MENY more wrappers there (adding pictures , links, drawing , painting, formating etc) so once you get into it, you can write easy very complex excel files.

Source is included so if something is missing or is not vay you like it you
can extend it or adjust it.

It BTW all startted with couple of Cetin's examples just like this one he gave you today :)

Have great Weekend :))
*****************
Srdjan Djordjevic
Limassol, Cyprus

Free Reporting Framework for VFP9 ;
www.Report-Sculptor.Com
Previous
Reply
Map
View

Click here to load this message in the networking platform