Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Edit excel file in form VFP
Message
De
14/06/2016 21:12:02
 
 
À
14/06/2016 08:42:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Divers
Thread ID:
01637287
Message ID:
01637340
Vues:
158
J'aime (1)
i dont find the owc11 component (dll),then i dont tried it.i found a donwload for office 2007 ( 8 Moctets !)

there is an old method to embed any application on a vfp form using APIs ( it embed here excel, but can be also word,notepad or something else).
of course excel must be installed .
*Use APIs to embed excel on a top level form
*Excel becomes a child of the form window by SetParent API.
*this works but causes many new problems.........

Publi yfrm
yfrm=Newobject("oexcel")
yfrm.Show
Read Events
Retu
*
Define Class oexcel As Form
	Height = 439
	Width = 707
	AutoCenter = .T.
	ShowWindow=2
	Caption = "Embed excel on a form"
	Name = "Form1"

	Add Object command2 As CommandButton With ;
		Top = 405, ;
		Left = 228, ;
		Height = 27, ;
		Width = 156, ;
		Caption = "Excel file....", ;
		Name = "Command2"

	Procedure Load
	Declare SetParent In user32 Integer hWndChild, Integer hWndParent
	Declare Integer SetWindowPos In User32 ;
		integer Wnd_handler, Integer Window_Order, ;
		integer X1, Integer Y1, Integer X2, Integer Y2, Integer wFlags
	Declare Long FindWindow In Win32API ;
		STRING lpClassName;
		,String lpWindowName
	Endproc

	Procedure Destroy
	loExcel=Null
	Release loExcel
	Clea Events
	Endproc

	Procedure command2.Click
	Local loExcel,loWorkBook
	loExcel = Createobject('excel.application')
	lcFile = Getfile('xls|xslx')
	If Empty(m.lcFile) Or ! Inlist(Lower(Justext(m.lcFile)),"xls","xlsx")
		Return .F.
	Endi
	loWorkBook = loExcel.Workbooks.Add(m.lcFile)
	oCaption=loExcel.Caption
	Excel_hwnd=FindWindow(Null,oCaption)
* messagebox(trans(oCaption +"    "+trans(Excel_hwnd)),0+32+4096,'',1200)
	If !Excel_hwnd=0
		SetParent(Excel_hwnd, Thisform.HWnd)
		SetWindowPos( Excel_hwnd,0,0,0,Thisform.Width-1,Thisform.Height-1,64)
	Else
		Messagebox("fails",16+4096)
	Endi

	loExcel.Visible = .T.
	Endproc

Enddefine
*
*-- EndDefine: oexcel
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform