Writing HTML as Rich Text

Topics: Developer Forum, User Forum
May 21, 2014 at 4:23 PM
Howdy,

I'm trying to write HTML into an excel document and have it appear in proper formatting. For instance, if a word appears inside <sup> tags, the word should appear in the excel document with superscript formatting. I have been trying to replace one type of tag and then another, but it erases my previous formatting (my code is below).
$tagCount1 = preg_match_all('/<sup[^>]*>(.*?)<\/sup>/is', $value1, $matches1);
$tagSplit1 = preg_split('/<sup[^>]*>(.*?)<\/sup>/is', $value1);
$objRichText1 = new PHPExcel_RichText();
for($k=0;$k<=$tagCount1;$k++){
    $objRichText1->createTextRun($tagSplit1[$k]);
    $objModified1 = $objRichText1->createTextRun($matches1[1][$k]);
    $objModified1->getFont()->setSuperScript(true);
}
                    $objPHPExcel->getActiveSheet()->getCell($column.$row)->setValue($objRichText1);
                    
$testValue = $objPHPExcel->getActiveSheet()->getCell($column.$row)->getFormattedValue();
//$testValue 
The $testValue does not contain the original formatting that I had done to it (the superscript in this case). Anyone know why this is happening or if there is an easier to write HTML as Rich Text?

Cheers,