0

我正在尝试使用 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***

谁能帮我解决这个错误?谢谢

4

2 回答 2

4

You are facing this problem because common office php files are missing. Download:

https://github.com/PHPOffice/Common

and include it in your source code (after updating the path):

require_once 'Common-develop/src/Common/Autoloader.php';
\PhpOffice\Common\Autoloader::register();
于 2015-07-23T01:07:21.593 回答
1

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

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

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

PS:不要忘记目标文件夹的写入权限,否则库将无法写出演示文件!

于 2016-01-27T20:40:25.920 回答