FINAL EDIT - ANSWERED BELOW - ISSUE: GROUPING_TYPE
I am new to PHPExcel and am having an issue when adding a chart via PHPExcel. I am currently only testing the Excel 2007 output version.
The remainder of the code (not included) is working properly, as a simple data file (without the chart code below) is downloadable and readable by Excel 2007 without error, however, when I add a chart (using the copy/pasted code below), upon opening the downloaded file in Excel I get the error Excel found unreadable content in:####. Do you want to recover the contents...
EDIT: Upon recovering the contents, the chart IS STILL PRESENT WITH ALL DATA INTACT.
Here is the code used to generate the chart:
//ADD THE REPORT SUMMARY CHART
$chrtCols = "'Report Summary'!B2:B$rowNum";
$chrtVals = "'Report Summary'!C2:C$rowNum";
$periods = new PHPExcel_Chart_DataSeriesValues('String', $chrtCols, null, $rowNum-1);
$values = new PHPExcel_Chart_DataSeriesValues('Number', $chrtVals, null, $rowNum-1);
$series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_LINECHART,
PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED,
array(0),
array(),
array($periods),
array($values)
);
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
$layout = new PHPExcel_Chart_Layout();
$plotarea = new PHPExcel_Chart_PlotArea($layout, array($series));
$chart = new PHPExcel_Chart('sample', null, null, $plotarea);
$chart->setTopLeftPosition('A1');
$chart->setBottomRightPosition('A18');
$actSheet->addChart($chart);
$rowNum is the last row of data.
Also, I am including the line $objWriter->setIncludeCharts(TRUE); prior to actually writing the file.
The file is also being downloaded using the proper MIME type for the Excel 2007 extension:
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, so I do not believe it is a header issue?
Anyone out there that can help? Basically, I just need to get rid of the error upon opening the file in Excel. Any thoughts?
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);line of code and still receive the same error. Any other thoughts? - IIIOXIIIEDIT. After repairing the file, the chart is available (it was previously improperly sized and hard to locate) and the data is in tact. The main problem I am having now is just getting rid of the "unreadable content" error upon opening the file. Thanks for your help. - IIIOXIIIGROUPING_CLUSTEREDshould perhaps beGROUPING_STANDARDas you're only working with a single dataseries - Mark Baker