PHPWord-如何将word公式呈现为html

PHPWord-如何将word公式呈现为html,php,ms-word,phpword,Php,Ms Word,Phpword,我有一个MS Word,表格内容,公式如下: Gabriel、Amanda、Lucas e Joelma estão fazendo uma competião para ver quem tem mais figure duálbum da Copa do mundo。加布里埃尔·康塞圭1/5,阿曼达9/10,卢卡斯·科卢·埃姆·修巴尔姆7/8,e·乔尔马1/2。O ganhador da competiçO foi 我的代码现在是这样的: $phpword = \PhpOffice\PhpW

我有一个MS Word,表格内容,公式如下:

Gabriel、Amanda、Lucas e Joelma estão fazendo uma competião para ver quem tem mais figure duálbum da Copa do mundo。加布里埃尔·康塞圭1/5,阿曼达9/10,卢卡斯·科卢·埃姆·修巴尔姆7/8,e·乔尔马1/2。O ganhador da competiçO foi

我的代码现在是这样的:

$phpword = \PhpOffice\PhpWord\IOFactory::load($file["tmp_name"]);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpword, 'HTML');
$xmlWriter = new \PhpOffice\Common\XMLWriter(\PhpOffice\Common\XMLWriter::STORAGE_MEMORY, './', \PhpOffice\PhpWord\Settings::hasCompatibility());

$contentHTML = $objWriter->getContent();

preg_match_all('/<table>(.*?)<\/table>/s', $contentHTML, $tables);
array_splice($tables[0], 0, 1);

foreach ($tables[0] as $key => $table) {
preg_match_all('/<tr>(.*?)<\/tr>/s', $table, $questionTables);

  foreach ($questionTables as $key2 => $questionTable) {
        // table content 

  }
}
$phpword=\phpooffice\phpword\IOFactory::load($file[“tmp_name”]);
$objWriter=\PhpOffice\PhpWord\IOFactory::createWriter($PhpWord,'HTML');
$xmlWriter=new\PhpOffice\Common\xmlWriter(\PhpOffice\Common\xmlWriter::STORAGE\u MEMORY,'./',\PhpOffice\PhpWord\Settings::haspatibility());
$contentHTML=$objWriter->getContent();
preg_match_all('/(.*?)/s',$contentHTML,$tables);
阵列拼接($tables[0],0,1);
foreach($tables[0]作为$key=>$table){
preg_match_all('/(.*?)/s',$table,$questionTables);
foreach($questionTables作为$key2=>$questionTable){
//表内容
}
}

现在我可以得到所有的文本和图像,但不能得到公式。有可能呈现这个吗?并将公式转换为image或base64?

您所说的公式是指1/5、9/10等?这可能是编码问题吗?@Vladan确实如此。这个1/5,9/10不呈现。如果这些分数是Word自动更正为“更好”的分数,那么我认为您需要确定这些字符的字体和ANSI/Unicode值。也许把它们放在某种“查找表”中。检查这些组合的单词内容,找到后,用“丑陋”版本(如问题中的块引号)替换代码。。。