Is it possible to create chart via PHPEXEL ?

Topics: Developer Forum
Jun 20, 2011 at 12:25 PM

Hi,  I need to add chatrs to exel I generate via PHPEXEL. Are there any functions or I should draw chart as GD image and then add it sheet ?

Something like this ?

 

// Generate an image

$gdImage = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream');
$textColor = imagecolorallocate($gdImage, 255, 255, 255);
imagestring($gdImage, 1, 5, 5, 'Created with PHPExcel', $textColor);

// Add a drawing to the worksheet

$objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
$objDrawing->setName('Sample image');
$objDrawing->setDescription('Sample image');
$objDrawing->setImageResource($gdImage);
$objDrawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
$objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT);
$objDrawing->setHeight(36);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());

With best regards Igor

 

Jun 22, 2011 at 8:25 PM

they are working on chart support, many are waiting for that update here, im the first one.... but there is another library that you can use for that pChart.

This one create a Chart with the parameters that you provide and it creates an Image, and that image you include it in you excel. so thats what you want.

Sorry i didnt read the rules of the forum ;-), i dont know if we can mention other libraries here.

Jun 22, 2011 at 9:17 PM

Thank you for help