Google chart + phpexcel ?

Apr 25, 2009 at 1:10 AM
someone have a tutorial to include google chart into spreadsheet
thx :)
Apr 25, 2009 at 8:43 AM
It should be possible to download a generated chart using file_get_contents(), for example. This can then be included as an image on the spreadsheet.
Apr 26, 2009 at 12:59 AM
set_include_path(get_include_path() . PATH_SEPARATOR . './Classes/');
require_once 'PHPExcel.php';
include 'PHPExcel/IOFactory.php';

//basic function to download chart
function charting($title,$val1,$val2,$color){
$url = file_get_contents("$title&chd=t:$val1,$val2&chtt=Example+Chart&chco=$color");
$img = fopen("chart.png", 'w');
fwrite($img, $url);

//create excel file
$objPHPExcel = new PHPExcel();
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Example Chart');
$objDrawing->setDescription('Example Chart');

//Write xlsx
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));


wORK ok. thx for the info :)