PHPExcel 显示图表不起作用
PHPExcel Display Charts not working
我正在尝试在网页上显示使用 PHPExcel 生成的 Excel 文件。该图像由条形图组成。我尝试使用
显示它
$objPHPExcel = new PHPExcel ();
$objWorksheet = $objPHPExcel->getActiveSheet ();
$objWorksheet->fromArray ( $data_array );
$dataseriesLabels = array (
new PHPExcel_Chart_DataSeriesValues ( 'String', 'Worksheet!$A', null, 3 ) ,
new PHPExcel_Chart_DataSeriesValues ( 'String', 'Worksheet!$A', null, 3 ),
new PHPExcel_Chart_DataSeriesValues ( 'String', 'Worksheet!$A', null, 3 )
);
$xAxisTickValues = array (
new PHPExcel_Chart_DataSeriesValues ( 'String', 'Worksheet!$B:$F', null, 3 ),
);
$dataSeriesValues = array (
new PHPExcel_Chart_DataSeriesValues ( 'Number', 'Worksheet!$B:$G', null, 6 ),
new PHPExcel_Chart_DataSeriesValues ( 'Number', 'Worksheet!$B:$G', null, 6 ),
new PHPExcel_Chart_DataSeriesValues ( 'Number', 'Worksheet!$B:$G', null, 6 )
);
$series = new PHPExcel_Chart_DataSeries ( PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping
range ( 0, count ( $dataSeriesValues ) - 1 ), // plotOrder
$dataseriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues ); // plotValues
$series->setPlotDirection ( PHPExcel_Chart_DataSeries::DIRECTION_COL );
$plotarea = new PHPExcel_Chart_PlotArea ( null, array ( $series) );
$legend = new PHPExcel_Chart_Legend ( PHPExcel_Chart_Legend::POSITION_RIGHT, null, false );
$title = new PHPExcel_Chart_Title ( 'Vendor Comparison Chart' );
$yAxisLabel = new PHPExcel_Chart_Title ( 'Rating' );
$chart = new PHPExcel_Chart ( 'chart1', $title, $legend,$plotarea,true, 0, null,$yAxisLabel );
$chart->setTopLeftPosition ( 'A7' );
$chart->setBottomRightPosition ( 'Q28' );
$objWorksheet->addChart ( $chart );
$objWriter = PHPExcel_IOFactory::createWriter ( $objPHPExcel, 'HTML' );
$objWriter->setIncludeCharts ( TRUE );
$objWriter->save ( "php://output" );
这只能输出 table 数据,但不会显示 excel 文件中的图表。任何帮助将不胜感激,因为我是 PHPExcel 的初学者。如何显示图表?
jpgraph 渲染器配置不正确
我正在尝试在网页上显示使用 PHPExcel 生成的 Excel 文件。该图像由条形图组成。我尝试使用
显示它$objPHPExcel = new PHPExcel ();
$objWorksheet = $objPHPExcel->getActiveSheet ();
$objWorksheet->fromArray ( $data_array );
$dataseriesLabels = array (
new PHPExcel_Chart_DataSeriesValues ( 'String', 'Worksheet!$A', null, 3 ) ,
new PHPExcel_Chart_DataSeriesValues ( 'String', 'Worksheet!$A', null, 3 ),
new PHPExcel_Chart_DataSeriesValues ( 'String', 'Worksheet!$A', null, 3 )
);
$xAxisTickValues = array (
new PHPExcel_Chart_DataSeriesValues ( 'String', 'Worksheet!$B:$F', null, 3 ),
);
$dataSeriesValues = array (
new PHPExcel_Chart_DataSeriesValues ( 'Number', 'Worksheet!$B:$G', null, 6 ),
new PHPExcel_Chart_DataSeriesValues ( 'Number', 'Worksheet!$B:$G', null, 6 ),
new PHPExcel_Chart_DataSeriesValues ( 'Number', 'Worksheet!$B:$G', null, 6 )
);
$series = new PHPExcel_Chart_DataSeries ( PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping
range ( 0, count ( $dataSeriesValues ) - 1 ), // plotOrder
$dataseriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues ); // plotValues
$series->setPlotDirection ( PHPExcel_Chart_DataSeries::DIRECTION_COL );
$plotarea = new PHPExcel_Chart_PlotArea ( null, array ( $series) );
$legend = new PHPExcel_Chart_Legend ( PHPExcel_Chart_Legend::POSITION_RIGHT, null, false );
$title = new PHPExcel_Chart_Title ( 'Vendor Comparison Chart' );
$yAxisLabel = new PHPExcel_Chart_Title ( 'Rating' );
$chart = new PHPExcel_Chart ( 'chart1', $title, $legend,$plotarea,true, 0, null,$yAxisLabel );
$chart->setTopLeftPosition ( 'A7' );
$chart->setBottomRightPosition ( 'Q28' );
$objWorksheet->addChart ( $chart );
$objWriter = PHPExcel_IOFactory::createWriter ( $objPHPExcel, 'HTML' );
$objWriter->setIncludeCharts ( TRUE );
$objWriter->save ( "php://output" );
这只能输出 table 数据,但不会显示 excel 文件中的图表。任何帮助将不胜感激,因为我是 PHPExcel 的初学者。如何显示图表?
jpgraph 渲染器配置不正确