include/chajian/PHPWordChajian.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php 
/**
*	PHPWord类
*/

class PHPWordChajian extends Chajian{
	
	private $vendorbool=false;
	
	protected function initChajian()
	{
		$path = ''.ROOT_PATH.'/include/vendor/autoload.php';
		if(file_exists($path)){
			require_once($path);
			$this->vendorbool = true;
		}
	}
	
	public function isbool()
	{
		return $this->vendorbool;
	}
	
	public function test()
	{
		if(!$this->vendorbool)return;
		
		\PhpOffice\PhpWord\Settings::loadConfig();
		
		\PhpOffice\PhpWord\Settings::setPdfRenderer(\PhpOffice\PhpWord\Settings::PDF_RENDERER_DOMPDF, ''.ROOT_PATH.'/include/vendor/dompdf/dompdf');
		\PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
		
		$languageEnGb = new \PhpOffice\PhpWord\Style\Language(\PhpOffice\PhpWord\Style\Language::EN_GB);

		$phpWord = new \PhpOffice\PhpWord\PhpWord();
		$phpWord->getSettings()->setThemeFontLang($languageEnGb);
		
		
		$section = $phpWord->addSection();
		// Adding Text element to the Section having font styled by default...
		$section->addText(
			'"Learn from yesterday, live for today, hope for tomorrow. '
				. 'The important thing is信呼 not to stop questioning." '
				. '(Albert Einstein)'
		);
		//$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
		//$objWriter->save('wfewew.docx');
		$phpWord->save('helloWorld'.time().'.pdf','PDF');
		
		
		
	}
	
	/**
	*	只能替换.docx
	*/
	public function replaceWord($path, $data=array(), $npath='')
	{
		if(!$this->vendorbool)return returnerror('未安装插件');
		
后面还有 9 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。