Problem Graph doesn't display

Topics: Developer Forum
Aug 5, 2013 at 8:14 AM
Edited Aug 5, 2013 at 8:15 AM
Hello,

I try to display a pie graph in my excel sheet, I take the code example because I didn't find documentation about this, all sheet work well but not the graph, I put the code below can help me and see me what is wrong.
Thanks a lot for your help
$objPHPExcel->getActiveSheet()->setCellValue('B5', $row_tissus[0]);
$objPHPExcel->getActiveSheet()->setCellValue('B6', '300');
$objPHPExcel->getActiveSheet()->setCellValue('B9', $row_tissus[1]);
$objPHPExcel->getActiveSheet()->setCellValue('B10', $row_tissus[2]);
$objPHPExcel->getActiveSheet()->setCellValue('B11', $row_tissus[3]);
$objPHPExcel->getActiveSheet()->setCellValue('B12', $row_tissus[4]);
$objPHPExcel->getActiveSheet()->setCellValue('B13', $row_tissus[5]);
$objPHPExcel->getActiveSheet()->setCellValue('B14', $row_tissus[6]);
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getStyle('A5:B14')->applyFromArray($styleArray);


$dataseriesLabels1 = array(
    new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$A$9', NULL, 1)
);

$xAxisTickValues1 = array(
        new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$A$9:$A$14', NULL, 6)  
);

$dataSeriesValues1 = array(
        new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$B$9:$B$14', NULL, 6)
);

$series1 = new PHPExcel_Chart_DataSeries(
        PHPExcel_Chart_DataSeries::TYPE_PIECHART,               // plotType
        PHPExcel_Chart_DataSeries::GROUPING_STANDARD,           // plotGrouping
        range(0, count($dataSeriesValues1)-1),                  // plotOrder
        $dataseriesLabels1,                                     // plotLabel
        $xAxisTickValues1,                                      // plotCategory
        $dataSeriesValues1                                      // plotValues
);

$layout1 = new PHPExcel_Chart_Layout();
$layout1->setShowVal(TRUE);
$layout1->setShowPercent(TRUE);

$plotarea1 = new PHPExcel_Chart_PlotArea($layout1, array($series1));

$legend1 = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);

$title1 = new PHPExcel_Chart_Title('Répartition des tissus');

$chart1 = new PHPExcel_Chart(
        'chart1',       // name
        $title1,        // title
        $legend1,       // legend
        $plotarea1,     // plotArea
        true,           // plotVisibleOnly
        0,              // displayBlanksAs
        NULL,           // xAxisLabel
        NULL            // yAxisLabel       - Pie charts don't have a Y-Axis
);

$chart1->setTopLeftPosition('C5');
$chart1->setBottomRightPosition('H20');

$objWorksheet->addChart($chart1);
Coordinator
Aug 5, 2013 at 8:38 AM
Edited Aug 5, 2013 at 8:39 AM
When saving, are you using
$objWriter->setIncludeCharts(TRUE);
and using the Excel2007b Writer?
Aug 5, 2013 at 8:44 AM
Many thanks thats run very well