Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHPExcel饼图_Php_Codeigniter_Phpexcel_Pie Chart - Fatal编程技术网

PHPExcel饼图

PHPExcel饼图,php,codeigniter,phpexcel,pie-chart,Php,Codeigniter,Phpexcel,Pie Chart,我已经在这个问题上纠缠了一段时间了。我似乎还是想不出路来。我无法获取PHPExcel的piechart示例,33chartcreate pie.php。我到处找,但似乎找不到好的答案,所以我决定自己去问。根据给出的例子,我尝试了这个。。我正在使用Codeigniter,因此我正在加载库$this->load->library('excel') 起初,我没有得到任何输出,然后我发现我使用的是Excel5。因此,我将类型更改为Excel2007,但仍然没有得到任何信息。事实上,当我将扩展名从.xls

我已经在这个问题上纠缠了一段时间了。我似乎还是想不出路来。我无法获取PHPExcel的piechart示例,33chartcreate pie.php。我到处找,但似乎找不到好的答案,所以我决定自己去问。根据给出的例子,我尝试了这个。。我正在使用Codeigniter,因此我正在加载库
$this->load->library('excel')

起初,我没有得到任何输出,然后我发现我使用的是Excel5。因此,我将类型更改为Excel2007,但仍然没有得到任何信息。事实上,当我将扩展名从.xlsx导出并更改为.xls时,我得到以下错误:
致命错误:在第3327行的path\application\third\u party\PHPExcel\Calculation.php中的非对象上调用成员函数celleexists()
我真的很感激你的帮助。谢谢你看这个。我希望一切都清楚。

这是我的工作

而不是:
$this->excel

使用:
$objPHPExcel
(但首先
$objPHPExcel=new PHPExcel();


而不是:
header('Content-Type:application/vnd.openxmlformats officedocument.spreadsheetml.sheet')
使用:
标题('Content-Type:application/vnd.ms-excel')

而不是:
header('Content\u Disposition:attachment;filename=“Report”)

使用:
标题('Content-Disposition:attachment;filename=“Report.xls”)

考虑将代码块包装在反勾(`)中,以使代码清晰
$dataseriesLabel1 = array(
        new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1),
);

$xAxisTickValues1 = array(
    new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4),
);

$dataSeriesValues1 = array(
    new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4),
);

$series1 = new PHPExcel_Chart_DataSeries(
    PHPExcel_Chart_DataSeries::TYPE_PIECHART,
    PHPExcel_Chart_DataSeries::GROUPING_STANDARD,
    range(0, count($dataSeriesValues1)-1),
    $dataseriesLabels1,
    $xAxisTickValues1,
    $dataSeriesValues1
);

$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('Test Pie Chart');

$chart1 = new PHPExcel_Chart(
    'chart1',
     $title1,
     $legend1,
     $plotarea1,
     true,
     0,
     NULL,
     NULL
);

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

$this->excel->getActiveSheet()->addChart($chart1);

header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content_Disposition: attachment;filename="Report"');
header('Cache-Control: max-age=0');

$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel2007');
$objWriter->setIncludeCharts(TRUE);
$objWriter->save('php://output');