Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to programmatically generate graph?
Message
De
05/01/2000 04:54:51
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Divers
Thread ID:
00312553
Message ID:
00313088
Vues:
62
>I would like to generate an MS Excel (V95) graph in code, and deliver it to a browser.
>
>This is still in the fuzzy planning stages. One thought is an inhouse user will generate an HTML file for e-mail, or this could possibly be responding to an outside client requesting the report through the web. Currently using VFP 5.0 so an ActiveDocument application is not an option.
>
>Any ideas are appreciated,
>
>
>Phil
>
>
>NOTE: I downloaded a utility from members.xoom.com/vkagarwal that is supposed to accomplish this, but I keep getting OLE error upon instantiation. Author has not tested this in VFP, so he could not offer any insight to the possible problem.


Philip,
I don't know of a way of doing that directly with Excel 95. With Excel and Word 97, you could copy chartarea, paste in word and saveas a web page (I don't remember if word95 supported web publishing). With Excel 2000 you could directly publish a graph to web or saveas as an HTML. Below code is compatible with VFP5 and Excel97, only last few lines publishing to web are Excel2000 compatible :
* Part of xlChartType constants
#DEFINE xl3DArea 					-4098
#DEFINE xl3DColumn					-4100
#DEFINE xl3DLine					-4101
#DEFINE xl3DPie						-4102
#DEFINE xlArea						1
#DEFINE xlBubble3DEffect			87
#DEFINE xlLine						4
#DEFINE xlPie						5
#DEFINE xlRadar						-4151
#DEFINE xlSurface					83

*** set the LOCALEID to English
nlLocaleId=sys(3004)		&& Save local id
=sys(3006,1033)			&& We will be sending instructions in English
ox = crea('excel.application')
ox.workbooks.add()
WITH ox.activeworkbook.worksheets(1)
  .Cells(1,1).Value = "Product"
  .Cells(1,2).Value = "AMount"
  .Cells(1,3).value = "Quota"
  .Cells(2,1).Value = "Prod1"
  .Cells(2,2).Value = 12000
  .Cells(2,3).value = 11000
  .Cells(3,1).Value = "Prod2"
  .Cells(3,2).Value = 45000
  .Cells(3,3).value = 48000
  .Cells(4,1).Value = "Prod3"
  .Cells(4,2).Value = 37000
  .Cells(4,3).value = 38000
  ox.charts.add
  ox.charts(1).chartwizard(.range(.Cells(1,1),.Cells(4,3)),xl3DColumn,4,1,0,1,1,"","","","")
ENDWITH
WITH ox.charts(1)
  .name = "My Chart"
  .hastitle = .t.
  .haslegend = .t.
  .ChartTitle.caption = "This is chart title"
  *	.ChartType=xlBubble3DEffect  && Set a charttype
  .plotby = 2
  * Now play with chart format
  #DEFINE xlCategory		1
  #DEFINE xlValue			2
  #DEFINE xlSeriesAxis	3
  WITH .Axes(xlValue)
    .hastitle = .T.
    WITH .AxisTitle
      .Caption = "This is Rotated Value title"
      .Font.Size = 10
      .Font.Bold = .f.
      .Orientation = 90 && Show 90 degrees rotated - clockwise
    ENDWITH
  ENDWITH
  *  .charttype = xl3DLine  && Change charttype in between
  *    	.PrintOut   && Print chart
  ox.visible = .t.
  #DEFINE xlSourceChart 5
  #DEFINE xlHTMLStatic 0
  #DEFINE xlHTMLChart 3
  ox.activeworkbook.PublishObjects.Add(xlSourceChart, ;
    "C:\temp\myChartTest.htm", "My Chart", "", xlHTMLStatic).Publish(.t.)
  #DEFINE xlHTML 44
  ox.activeworkbook.SaveAs("c:\temp\myExcelFile.htm", xlHTML)
ENDWITH
*oX.activeworkbook.saved = .t. && Suppress save dialog
*oX.quit      && Quit excel
=sys(3006,val(nlLocaleId))
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform