Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Graphing in Excel
Message
From
19/11/2004 03:37:43
 
 
To
19/11/2004 02:16:56
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP1
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00961925
Message ID:
00962904
Views:
12
Hi,
You could get full list of MSGraph object model and hierarchy from its help file VBAGR10.chm. It is shipped together with MSDN library.

I am not sure the reasons you need to automate Excel. However, if you only need to view and print graph, you can use general field. Bind it to oleBoundControl and place it on form. Then you can control its behavour as usual automation. VBAGR10.chm would be very helpful then.

Check out "Adding OLE Objects to Applications" for more information.

Here simple sample. Hope it helps.
PUBLIC loForm

LOCAL lcStr

#DEFINE ccTAB	CHR(9)
#DEFINE ccCRLF	CHR(13) + CHR(10)

CREATE CURSOR myData (Subject C(10), Marks N(6,2))

INSERT INTO myData VALUES ("English", 80)
INSERT INTO myData VALUES ("Math", 75)
INSERT INTO myData VALUES ("Bio", 68)
INSERT INTO myData VALUES ("Science", 88)

lcStr = "Subjects" + ccTAB + "Marks" + ccCRLF

SELECT myData
SCAN
	lcStr = lcStr + myData.Subject + ccTAB + TRANSFORM(Marks) + ccCRLF
ENDSCAN

CREATE CURSOR csrGraph (myGraph G)
APPEND BLANK
APPEND GENERAL myGraph DATA lcStr CLASS MSGraph.Chart

loForm = CREATEOBJECT("myGraphForm")
loForm.Show()

DEFINE CLASS myGraphForm AS Form
	
	ADD OBJECT oGraph AS OleBoundControl
	ADD OBJECT chkLegend AS CheckBox
	
	PROCEDURE INIT
		WITH THIS
			
			WITH .oGraph
				.ControlSource = "csrGraph.myGraph"
				.VISIBLE = .T.
				.HEIGHT = THIS.Height - 10
				.WIDTH = THIS.Width
			 	
			 	WITH .OBJECT
					.LEFT = 1
					.TOP = 1
					
					*-- OLE Automation
					.HasLegend = .T.
					.HasTitle = .T.
					.ChartTitle.Caption = "Result"
				ENDWITH
			ENDWITH
			
			WITH .chkLegend
				.CAPTION = "Has Legend"
				.TOP = THISFORM.Height - 20
				.Value = .T.
			ENDWITH
		ENDWITH
	ENDPROC
	
	PROCEDURE chkLegend.Click
		WITH THISFORM.oGraph.OBJECT
			.HasLegend = THIS.Value
		ENDWITH
	ENDPROC
ENDDEFINE
HTH
I am not the most powerful man in this world.
I am not the worst man in this world either.
I just as same as all of you.
I still need to learn from my mistakes...
Previous
Reply
Map
View

Click here to load this message in the networking platform