php ci try catch,PHPOffice/Common使用PHPWord在codeigniter中找不到

"此篇博客讲述了开发者在使用PHPWord库创建Word文档时遇到的ClassNotFoundException,展示了如何检查并修复'CommonText'类加载问题,包括自动加载设置和文件路径问题。"
摘要由CSDN通过智能技术生成

A PHP Error was encountered

Severity: Error

Message: Class 'PhpOffice\Common\Text' not found

Filename: Element/Text.php

Line Number: 139

include_once(APPPATH."third_party/PHPWord/Autoloader.php");

if (!defined('BASEPATH'))

exit('No direct script access allowed');

use PhpOffice\PhpWord\Autoloader;

use PhpOffice\PhpWord\Settings;

Autoloader::register();

Settings::loadConfig();

class Test extends CI_Controller {

public function index() {

$phpWord = new \PhpOffice\PhpWord\PhpWord();

$phpWord->getCompatibility()->setOoxmlVersion(14);

$phpWord->getCompatibility()->setOoxmlVersion(15);

$section = $phpWord->addSection();

$html = '

$filename = 'test.doc';

\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);

$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');

$objWriter->save($filename);

header('Content-Description: File Transfer');

header('Content-Type: application/octet-stream');

header('Content-Disposition: attachment; filename='.$filename);

header('Content-Transfer-Encoding: binary');

header('Expires: 0');

header('Cache-Control: must-revalidate, post-check=0, pre-check=0');

header('Pragma: public');

header('Content-Length: ' . filesize($filename));

flush();

readfile($filename);

unlink($filename); // deletes the temporary file

exit;

}

}

請幫助。

2017-08-30

woninana

+0

分享您的控制器代碼。 –

+0

@Tpojka編輯我的問題與控制器代碼 –

+0

我不知道'共同'和文檔鏈接是什麼被打破。但我明白你的主要問題是'PHPWord'。對? –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值