Quantcast
Channel: PHPWord
Viewing all articles
Browse latest Browse all 450

New Post: The Office Open XML file cannot be opened because there are problems with the contents.

$
0
0
Whats is the value of $course?

In somewhere you have to use iconv() function to convert charset of text you want to write to UTF since PHPWord accept only UTF8 as charset and also you have to change setValue function as below
public function setValue($search, $replace) {
    if(substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') {
        $search = '${'.$search.'}';
    }

      preg_match_all('/\$[^\$]+?}/', $this->_documentXML, $matches);

    for ($i=0;$i<count($matches[0]);$i++){

    $matches_new[$i] = preg_replace('/(<[^<]+?>)/','', $matches[0][$i]);

    $this->_documentXML = str_replace($matches[0][$i], $matches_new[$i], $this->_documentXML);
    }        

    /*if(!is_array($replace)) {
        $replace = utf8_encode($replace);
    }*/

    $this->_documentXML = str_replace($search, $replace, $this->_documentXML);
}

Viewing all articles
Browse latest Browse all 450

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>