tags:

views:

1557

answers:

5

Hello,

Do you have any idea on how to create a chart in an Excel sheet programmatically from PHP ?

I know you can invoke the Excel COM object, but the server is running on a Linux machine...

I already use the excellent PHPExcel library but they do not offer the option to create charts.

Thanks !

+3  A: 

Give Google Charts API a go. This link will shed some light

Aonther option you could look at is RRD tool, see here

HTH

Anand
I like the suggestion of using Google Charts, I didn't even think of that right off the bat.
monksy
Good idea ! You can then paste the image of the chart using:file_put_contents('graph.png', file_get_contents($GOOGLE_CHART_PATH));
Amadeus45
A: 

I don't believe that using Excel is the best way of generating a chart. Typically, with ASP.net, you would either write your own chart rendering, or you would use an external component to do this (liberal definition).

My suggestions:

  1. Pipe the data into gnuplot, customize it and grab the output
  2. Get a third party widget to send the data into and handle the user interaction (Highly recommended)
  3. Write your own chartting control (free from licensing issues, but not worth the annoyances unless you really like doing graphics your self)
monksy
A: 

Google Charts is a nice idea. I would use built-in PHP draw functions to generate a chart, though.

Anthoni Caldwell
A: 

Mabe you can try some third party java excel component.

One option is SmartXLS,it is a pure java component which support create/read/write most excel features(formulas,charts,pivotables,etc).

liya
A: 

I think it's not a bad idea to use PHPs GD library like these

WS Charts

Bar graph tutorial

or JpGraph, I'm not sure of the internals but there is free PHP5 and PHP4 versions available

aland