Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Yousfi Benameur
  Where is Yousfi Benameur?
 El Bayadh
 Algeria
 Yousfi Benameur
 To: naveed shahid
  Where is naveed shahid?
 
 Pakistan
 naveed shahid
 Tags
Subject: RE: open excel file on vfp form
Thread ID: 310641 Message ID: 310727 # Views: 40 # Ratings: 1
Version: Visual FoxPro 9 Category: Forms
Date: Thursday, June 23, 2011 9:11:23 PM         
   


> Hi,
>
> I have excel file (myfile.xls) and want to open it on VFP form.
>
> is it possible?
>
> naveed

i give for all this solution but for viewing only any excel file.
i create a cursor (from any select statment) and export it to excel.then i use the readonly property documentfile of the oleObject to open the file and view it on the form.
i disable the dblclick for editing the excel file but the back makes some problems.


*!*embed an excel file  on form to view only (not to edit).
close data all
sele * from  (home()+"samples\data\customer") into cursor ycurs
sele ycurs
copy to c:\asup.xls xl5
use in ycurs

publi yform
yform =NewOBJECT('asup')  
with yform
  .AddObject("oleObject","oleExcelObject")  
 with .oleObject
  .Visible=.T.  
  .left=15
  .top=15
  .Height = yform.height+30 && to fire the form scrollbars
  .width=yform.width+30
 endwith
.Show  ()
endwith
READ EVENTS  

DEFINE CLASS oleExcelObject as OLEControl
   OleClass ="Excel.Sheet"  
   DocumentFile = "c:\asup.xls"    &&or any excel file with :getfile('xls')  && This file must exist 
   autoactivate=.f.  && mandatory otherwise a dblclick open excel to edit but the back makes some unexpected problems.
ENDDEFINE

DEFINE CLASS asup as form
backcolor=rgb(0,255,0)
scrollbars=3
showWindow=2
width=800
height=600
autocenter=.t.
caption="Embedding excel object for viewing"
name ="form1"

procedure init
dodefault()
bindevent(thisForm ,"QueryUnLoad",thisForm ,"my")
endproc

procedure my()
clea events
endproc

enddefine


this is a photo


NB : can use API to load as child window the excel one in the parent window (form) but this dont work because the ribbon....
i have posted a sample for word in this forum...can search.

update:
in past can use IE to navigate to an excel file. Excel was embed in the browser ( on a form here).But for some security facts this dont work and fires the excel window separatly breaking all the best old things.

Regards
Yousfi Benameur

ENTIRE THREAD

open excel file on vfp form Posted by naveed shahid @ 6/23/2011 6:30:00 AM
RE: open excel file on vfp form Posted by Glen Villar @ 6/23/2011 6:33:37 AM
RE: open excel file on vfp form Posted by naveed shahid @ 6/23/2011 6:55:58 AM
RE: open excel file on vfp form Posted by naveed shahid @ 6/23/2011 8:08:02 AM
RE: open excel file on vfp form Posted by Yousfi Benameur @ 6/23/2011 9:11:23 PM