How to read subscript/superscript using PHPExcel library?

if ($objPHPExcel->getActiveSheet()->getCell($cell)->getValue() instanceof PHPExcel_RichText) { // $plaintext = $objPHPExcel->getActiveSheet()->getCell($cell)->getValue()->getPlainText(); $cellValueAsString = ''; $elements = $objPHPExcel->getActiveSheet()->getCell($cell)->getValue()->getRichTextElements(); foreach ($elements as $element) { // Rich text start? if ($element instanceof PHPExcel_RichText_Run) { if ($element->getFont()->getSuperScript()) { $cellValueAsString .= ''; } else if ($element->getFont()->getSubScript()) { $cellValueAsString .= ''; } } // Convert UTF8 data to PCDATA $cellText = $element->getText(); $cellValueAsString .= htmlspecialchars($cellText); if ($element instanceof PHPExcel_RichText_Run) { if ($element->getFont()->getSuperScript()) { $cellValueAsString .= ''; } else if ($element->getFont()->getSubScript()) { $cellValueAsString .= ''; } } } echo $cellValueAsString;