Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: FoxPro FAQ

COM and Automation

How to use Office Web Components to create a chart. by Mike Gagnon
Posted: 9 Mar 03 (Edited 10 Mar 03)

The following creates a Jpeg picture of a chart you can use in your application on forms, in reports etc... This example sends the chart to the Internet Explorer.
This requires Microsoft's Office Web Components. (http://office.microsoft.com/downloads/2002/owc10.aspx).

Local i
Store 0 To i
Dimension laLabels[3]
Dimension laData[3]
Dimension laData2[3]
Create Cursor final (pic m)
Create Cursor sales (Name c(20),total1 N(10),total2 N(10))
Insert Into sales (Name,total1,total2) Values ("Total sales Mike",1000,2000)
Insert Into sales (Name,total1,total2) Values ("Total sales Frank",2550,2500)
Insert Into sales (Name,total1,total2) Values ("Total sales Fred",1292,500)
Go Top
Do While !Eof()
    i = i +1
    Select sales
loChartSpace = Createobject("OWC10.ChartSpace")
oConst = loChartSpace.Constants
loGraph = loChartSpace.Charts.Add()
loGraph.Type =47
loGraph.HasLegend = .T.
loChartSpace.HasChartSpaceTitle = .T.
loChartSpace.ChartSpaceTitle.Caption = "Monthly Sales for My Company Inc."
loChartSpace.ChartSpaceTitle.Font.Bold = .T.
loGraph.SeriesCollection(0).Caption = "Sales of widgets #1"
loGraph.SeriesCollection(0).SetData(oConst.chDimCategories, oConst.chDataLiteral, @laLabels)
loGraph.SeriesCollection(0).SetData(oConst.chDimValues, oConst.chDataLiteral, @laData)
loGraph.SeriesCollection(1).Caption = "Sales of widgets #2"
loGraph.SeriesCollection(1).SetData(oConst.chDimValues, oConst.chDataLiteral, @laData2)
lcFile = Sys(2023) + "\" + Sys(2015) + ".jpg"
loChartSpace.ExportPicture(lcFile, "jpg",800,600)
oBrowser = CREATEOBJECT("internetexplorer.application")
oBrowser.visible = .t.

P.S. Some of this code was partially written by Rick Strahl.

Mike Gagnon

Back to Microsoft: FoxPro FAQ Index
Back to Microsoft: FoxPro Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close