>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)
.
.
.
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 :))