首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP Powerpoint和图表

PHP Powerpoint和图表
EN

Stack Overflow用户
提问于 2012-07-24 21:48:41
回答 4查看 11.7K关注 0票数 6

我正在尝试使用此library通过PHP创建PowerPoint演示文稿。当我尝试在PowerPoint中创建图表对象时,当我下载文件并在Microsoft Office中打开图表时,我无法编辑图表。

是否有库可以在PowerPoint文件中构建图表,并允许通过Office PowerPoint对其进行编辑?

Sample Chart created using the above library

EN

回答 4

Stack Overflow用户

发布于 2012-07-29 20:42:15

这很可能是PHP Power Point的一个错误。

但是,最新版本的PHPExcel支持图表功能,并且正在积极维护。它允许您图表和导出您的数据在excel中,可以很容易地复制到PowerPoint。

不过,就个人而言,我建议您使用Google Chart ToolsRaphaelJS

如果您希望能够在PowerPoint中使用图表,您可以轻松地将Google Charts Data导出到Excel (CSV)。另请参阅this example

如果你特别介绍谷歌分析,你应该阅读this document关于如何从谷歌分析在PowerPoint中创建一个准确的自动更新的图表和数据。它基本上使用PowerPoint的oomfo plugin

或者,也有像ShufflePoint这样的付费解决方案。

票数 6
EN

Stack Overflow用户

发布于 2012-12-22 16:55:00

当然,您可以使用PHPPowerPoint导出可编辑图表。在测试中有两个示例。第一个示例不包括Excel工作表,这就是图表不可编辑的原因。但如果你看看第二个例子,我想是test8,你会看到有一个对PHPExcel的引用调用和一个包含数据表和图表的标志,然后你就可以编辑数据了。

票数 3
EN

Stack Overflow用户

发布于 2012-08-01 17:58:34

查看这个url:-

PHP PowerPoint 2007类

该项目为PHP语言提供了一组类,允许您对不同的文件格式进行写入和读取,如PowerPoint 2007,...这个项目是围绕微软的OpenXML标准和PHP构建的。

http://phppowerpoint.codeplex.com/

http://phppowerpoint.codeplex.com/sourcecontrol/list/changesets?ProjectName=phppowerpoint

特性

http://phppowerpoint.codeplex.com/wikipage?title=Features&referringTitle=Home

试试这个:-

代码语言:javascript
复制
<?php
/** Error reporting */
error_reporting(E_ALL);

/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . '/Classes/');

/** PHPPowerPoint */
include 'Classes/PHPPowerPoint.php';

// Create new PHPPowerPoint object
$objPHPPowerPoint = new PHPPowerPoint();
$objPHPPowerPoint->getProperties()->setCreator("Maarten Balliauw")->
    setLastModifiedBy("Maarten Balliauw")->setTitle("Office 2007 PPTX Test Document")->
    setSubject("Office 2007 PPTX Test Document")->setDescription("Test document for Office 2007 PPTX, generated using PHP classes.")->
    setKeywords("office 2007 openxml php")->setCategory("Test result file");

// Remove first slide
$objPHPPowerPoint->removeSlideByIndex(0);

// Create templated slide

// Create templated slide
$currentSlide = createTemplatedSlide($objPHPPowerPoint);

// Generate sample data for line chart
$seriesData = array('Jul 17' => 15, 'Jul 18' => 27, 'Jul 19' => 17, 'Jul 20' =>
    11, 'Jul 21' => 7, 'Jul 22' => 2, 'Jul 23' => 8);

// Create a line chart (that should be inserted in a shape)
$lineChart = new PHPPowerPoint_Shape_Chart_Type_Scatter();
$series = new PHPPowerPoint_Shape_Chart_Series('Visits', $seriesData);
//$series->setShowSeriesName(true);
$lineChart->addSeries($series);

// Create a shape (chart)
$shape = $currentSlide->createChartShape();
$shape->setName('# of people visiting your website')->setResizeProportional(false)->setHeight(550)->
    setWidth(700)->setOffsetX(120)->setOffsetY(80);
$shape->getShadow()->setVisible(true)->setDirection(45)->setDistance(10);
$shape->getFill()->setFillType(PHPPowerPoint_Style_Fill::FILL_GRADIENT_LINEAR)->
    setStartColor(new PHPPowerPoint_Style_Color('FFCCCCCC'))->setEndColor(new
    PHPPowerPoint_Style_Color('FFFFFFFF'))->setRotation(270);
$shape->getBorder()->setLineStyle(PHPPowerPoint_Style_Border::LINE_SINGLE);
$shape->getTitle()->setText('# of people visiting your website');
$shape->getTitle()->getFont()->setItalic(true);
$shape->getPlotArea()->setType($lineChart);
$shape->getView3D()->setRotationX(30);
$shape->getView3D()->setPerspective(30);
$shape->getLegend()->getBorder()->setLineStyle(PHPPowerPoint_Style_Border::
    LINE_SINGLE);
$shape->getLegend()->getFont()->setItalic(true);

// Save PowerPoint 2007 file
$objWriter = PHPPowerPoint_IOFactory::createWriter($objPHPPowerPoint,
    'PowerPoint2007');
$objWriter->save(str_replace('.php', '.pptx', __file__));

function createTemplatedSlide(PHPPowerPoint $objPHPPowerPoint) {
    // Create slide
    $slide = $objPHPPowerPoint->createSlide();

    // Return slide
    return $slide;
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11632297

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档