Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to copy an Excel Chart and save it as JPG/GIf
Message
De
03/06/2003 02:52:10
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
02/06/2003 13:34:05
Peter Wagner
Point Informática Ltda.
Limeira, Brésil
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00795319
Message ID:
00795542
Vues:
18
>I have a customer that wants to copy the chart created whith automation by VFP and save it as an image file like .jpg or .gif. so it can call this chart by IE.
>
>Does someone knows how to copy the chart and save it as a file ?
>
>Thanks in advance
>
>Peter

Peter,
Is your intention to save the chart as a GIF or to publish it as an HTM (GIF included by default) ?
Use PublishObjects().Publish method. It creates excel chart, sheet etc as an HTM either static or interactive. ie:
* 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
  oChart = .ChartObjects.Add(0, 0, 500, 200)
  oChart.Chart.chartwizard(;
      .Range(.Cells(1,1),.Cells(4,3)),xl3DColumn,4,1,0,1,1,"","","","")
Endwith
With oChart.Chart
  .hastitle = .T.
  .haslegend = .T.
  .ChartTitle.Caption = "This is chart title"
  .plotby = 2
  * Now play with chart format
  #Define xlCategory		1
  #Define xlValue		2
  #Define xlSeriesAxis	3
  With .Axes(xlValue)
    .hastitle = .T.
    With .AxisTitle
      .Caption = "Rotated Value title"
      .Font.Size = 10
      .Font.Bold = .F.
      .Orientation = 90 && Show 90 degrees rotated - clockwise
    Endwith
  Endwith

  #Define xlSourceChart 5
  #Define xlHTMLStatic 0
  #Define xlHTMLChart 3
  ox.activeworkbook.PublishObjects.Add(;
    xlSourceChart, "C:\temp\EXCELHTMLExportTest.htm", ;
    ox.activeworkbook.worksheets(1).Name,.Parent.Name, ;
    xlHTMLStatic, "", "Published From Excel").Publish(.T.)
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