Thursday, November 5, 2009

Draw 3D pie diagram in Excel from magik

This piece of code will help to draw a 3d pie diagram in excel sheet from magik..


e << OLE_Client.Create_Object("Excel.Application")
w << e.Workbooks()

s << e.Sheets("Sheet1")
s.Name << "bhimu"
_for i _over range (1,10)
Cell << S.Range ("A"+i.print_string)
Cell.Value << i
Cell.Release_Object ()
Cell << S.Range ("B"+i.print_string)
Cell.Value << "=A"+i.print_string+"*"+"A"+i.print_string
Cell.Release_Object ()

c << e.charts.add
c.ChartType << :|xl3DPieExploded|
e.ActiveChart.Location(:|xlLocationAsObject|, "bhimu")
e.Visible << _True


if location is not specified, then the chart is added to a new sheet.


  1. Hi Bhimesh,

    Very nice. I copied/pasted the code into my Magik session and got the 3D pie chart in an Excel spreadsheet!

    So for your next Magik Fun challenge, maybe you could modify the the Excel graph code to use the Google Charts API ( You could make HTTP requests from Magik that call the Google Charts API and then do something with the returned chart picture. Core Magik doesn't have any easy-to-use classes for making HTTP requests, but if you go to the SourceForge MagikCmpnts community and download, you can browse to \modules\mclib_http_connection\examples\yahoo_maps_interface.magik to see an example of how to use the mclib:http_request class for making a request.

    Good luck with your new blog!


  2. i am trying http_connection examples... but as my system is behind the fire walls, it is giving traceback,

    sw_net_acp.get_host_by_nam"") is raising a condition sayin sw_net_lookup failed....

  3. I think that the http_connection might not handle web server proxies. In that case you could use cURL ( This is a command-line executable that you can call from Magik but you can also specify the proxy server username/password. Let me know how it goes.