Phpword数据未在图表中显示

时间:2018-01-10 04:11:05

标签: php phpword

这是phpword的示例代码,用于制作微软单词中的图表

<?php
require_once 'vendor/autoload.php';
use PhpOffice\PhpWord\Shared\Converter;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$categories = array('A', 'B', 'C', 'D', 'E');
$series1 = array(5, 3, 4, 2, 7);

$chart = $section->addChart('column', $categories, $series1);
$chart->getStyle()->setWidth(Converter::inchToEmu(2.5))->setHeight(Converter::inchToEmu(2));

header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment;filename="test.docx"');
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('php://output');
?>

当代码运行并保存到Microsoft Word时,数据由图表中未显示的变量声明。

Click this to see the chart

0 个答案:

没有答案