// Data Marker $xAxisTickValues2 = array(new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4)); // Set the Data values for each data series we want to plot // Datatype // Cell reference for data // Format Code // Number of datapoints in series // Data values // Data Marker $dataSeriesValues2 = array(new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4)); // Build the dataseries $series2 = new PHPExcel_Chart_DataSeries(PHPExcel_Chart_DataSeries::TYPE_DONUTCHART, NULL, range(0, count($dataSeriesValues2) - 1), $dataSeriesLabels2, $xAxisTickValues2, $dataSeriesValues2); // Set up a layout object for the Pie chart $layout2 = new PHPExcel_Chart_Layout(); $layout2->setShowVal(TRUE); $layout2->setShowCatName(TRUE); // Set the series in the plot area $plotArea2 = new PHPExcel_Chart_PlotArea($layout2, array($series2)); $title2 = new PHPExcel_Chart_Title('Test Donut Chart'); // Create the chart $chart2 = new PHPExcel_Chart('chart2', $title2, NULL, $plotArea2, true, 0, NULL, NULL); // Set the position where the chart should appear in the worksheet $chart2->setTopLeftPosition('I7'); $chart2->setBottomRightPosition('P20'); // Add the chart to the worksheet $objWorksheet->addChart($chart2); // Save Excel 2007 file echo date('H:i:s'), " Write to Excel2007 format", EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->setIncludeCharts(TRUE); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
// Data Marker $xAxisTickValues2 = array(new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4)); // Set the Data values for each data series we want to plot // Datatype // Cell reference for data // Format Code // Number of datapoints in series // Data values // Data Marker $dataSeriesValues2 = array(new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4)); // Build the dataseries $series2 = new PHPExcel_Chart_DataSeries(PHPExcel_Chart_DataSeries::TYPE_DONUTCHART, PHPExcel_Chart_DataSeries::GROUPING_STANDARD, range(0, count($dataSeriesValues2) - 1), $dataseriesLabels2, $xAxisTickValues2, $dataSeriesValues2); // Set up a layout object for the Pie chart $layout2 = new PHPExcel_Chart_Layout(); $layout2->setShowVal(true); $layout2->setShowCatName(true); // Set the series in the plot area $plotarea2 = new PHPExcel_Chart_PlotArea($layout2, array($series2)); $title2 = new PHPExcel_Chart_Title('Test Donut Chart'); // Create the chart $chart2 = new PHPExcel_Chart('chart2', $title2, null, $plotarea2, true, 0, null, null); // Set the position where the chart should appear in the worksheet $chart2->setTopLeftPosition('I7'); $chart2->setBottomRightPosition('P20'); // Add the chart to the worksheet $objWorksheet->addChart($chart2); // Save Excel 2007 file echo date('H:i:s'), " Write to Excel2007 format", EOL; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->setIncludeCharts(true); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));