找不到PhpPowerpoint类XMLwriter

时间:2015-07-21 14:13:42

标签: php xmlwriter phppowerpoint

我试图使用PHPPowerpoint和他的例子

但是我收到以下错误:

*Sample 01 Complex
14:56:03 Create new PHPPresentation object
14:56:03 Set properties
14:56:03 Remove first slide
14:56:03 Create templated slide
14:56:03 Create a shape (rich text)
14:56:03 Create templated slide
14:56:03 Create a shape (rich text)
14:56:03 Create a shape (rich text)
14:56:03 Create templated slide
14:56:03 Create a shape (rich text)
14:56:03 Create a shape (rich text)
14:56:03 Create templated slide
14:56:03 Create a shape (rich text)
14:56:03 Create a shape (rich text)

**Fatal error: Class 'Common\XMLWriter' not found in .....\test phppowerpoint\PHPPowerPoint-develop\src\PhpPresentation\Writer\PowerPoint2007\AbstractPart.php on line 76***

任何人都可以帮我修复此错误吗? 谢谢

2 个答案:

答案 0 :(得分:4)

您遇到此问题,因为缺少common office php个文件。下载:

https://github.com/PHPOffice/Common

并将其包含在源代码中(更新路径后):

require_once 'Common-develop/src/Common/Autoloader.php';
\PhpOffice\Common\Autoloader::register();

答案 1 :(得分:1)

正如Raj所说,您需要从他指定的链接下载常见的PHPOffice类。 您可以将它们放在更方便的地方。在我的例子中,我将 Common 文件夹放在 src 文件夹中(所以在 src 中你有 PHPPresentation Common )。 然后,你需要将它们包含在源代码中,如Raj所说

require_once 'PHPPresentation/src/Common/Autoloader.php;
\PhpOffice\Common\Autoloader::register();

您必须将 require_once 中的路径更新为实际路径。

P.S。:不要忘记在目标文件夹上写权限,否则库将无法写出演示文件!