Friday, July 16, 2004

Refresh MS Graph data in VFP

VFP doesn't come with Graph control. However, VFP provides wizard for us to generate graph using MS Graph. It would be a static graph. It doesn't refresh by itself even your query result has changed. It is because VFP has "hard coded" data into graph's datasheet while generating.

Fortunely, we still able to change your graph content programmatically through automation. Here is a simple sample which would "refresh" MS Graph content generated by VFP's graph wizard. It shows :
  1. How to change value of particular column/row in MS Graph's datasheet.
    THISFORM.oChart.OBJECT.Application.DataSheet ;
    
    .Range("A2").Value = "10"
  2. How to import XLS file to MS Graph and display it.
    THISFORM.oChart.OBJECT.Application.FileImport(lcXLS)
    
I would prefer to use import XLS way to refresh the graph because VFP could export VFP cursor to XLS file easily with command
     COPY TO drive:\myXLS.xls TYPE XLS
NOTE: Before this, please make sure MS Excel (full pack version) is installed in your machine. Otherwise you would cause OLE error.

Beside, we also able to customize our graph just simple as automation. What we need is VBAGR10.chm, help file of MS Graph which come along with MSDN library. It shows MS Graph object hierarchy and interfaces. Have a look and try it now! Have fun!

0 Comments:

Post a Comment

<< Home