时间:2021-07-01 10:21:17 帮助过:16人阅读
require_once '../PHPWord.php';$PHPWord = new PHPWord();$document = $PHPWord->loadTemplate('Template.docx');print_r($document);exit;
但那是私有的属性
在这个类中,一定有某个方法是用来操作这个属性的
但那是私有的属性
在这个类中,一定有某个方法是用来操作这个属性的
谢谢,下面是这个类的文件,能不能帮忙看一下如何调用啊_tempFileName = $path.DIRECTORY_SEPARATOR.time().'.docx'; copy($strFilename, $this->_tempFileName); // Copy the source File to the temp File $this->_objZip = new ZipArchive(); $this->_objZip->open($this->_tempFileName); $this->_documentXML = $this->_objZip->getFromName('word/document.xml'); } /** * Set a Template value * * @param mixed $search * @param mixed $replace */ public function setValue($search, $replace) { if(substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { $search = '${'.$search.'}'; } if(!is_array($replace)) { $replace = utf8_encode($replace); } $this->_documentXML = str_replace($search, $replace, $this->_documentXML); } /** * Save Template * * @param string $strFilename */ public function save($strFilename) { if(file_exists($strFilename)) { unlink($strFilename); } $this->_objZip->addFromString('word/document.xml', $this->_documentXML); // Close zip file if($this->_objZip->close() === false) { throw new Exception('Could not close zip file.'); } rename($this->_tempFileName, $strFilename); }}?>
public function save($strFilename) { if(file_exists($strFilename)) { unlink($strFilename); } $this->_objZip->addFromString('word/document.xml', $this->_documentXML); // Close zip file if($this->_objZip->close() === false) { throw new Exception('Could not close zip file.'); } rename($this->_tempFileName, $strFilename); }这个方法就是保存到文件
public function save($strFilename) { if(file_exists($strFilename)) { unlink($strFilename); } $this->_objZip->addFromString('word/document.xml', $this->_documentXML); // Close zip file if($this->_objZip->close() === false) { throw new Exception('Could not close zip file.'); } rename($this->_tempFileName, $strFilename); }这个方法就是保存到文件
public function show() { if(file_exists($strFilename)) { unlink($strFilename); } return $this->_documentXML; }
if(file_exists($strFilename)) {
unlink($strFilename);
}
这个不要!