Additional examples for HTML to Rich Text helper (superscript and subscript)

This commit is contained in:
MarkBaker 2015-01-13 23:44:38 +00:00
parent 98f4754048
commit 16f2eb63a1

View File

@ -78,11 +78,16 @@ $html2='<p>
</font> </font>
</p>'; </p>';
$html3='2<sup>3</sup> equals 8';
$html4='H<sub>2</sub>SO<sub>4</sub> is the chemical formula for Sulphuric acid';
$wizard = new PHPExcel_Helper_HTML; $wizard = new PHPExcel_Helper_HTML;
$richText = $wizard->toRichTextObject($html1); $richText = $wizard->toRichTextObject($html1);
$objPHPExcel->setActiveSheetIndex(0) $objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', $richText); ->setCellValue('A1', $richText);
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(48); $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(48);
$objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(-1); $objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(-1);
@ -93,13 +98,19 @@ $objPHPExcel->getActiveSheet()->getStyle('A1')
$richText = $wizard->toRichTextObject($html2); $richText = $wizard->toRichTextObject($html2);
$objPHPExcel->setActiveSheetIndex(0) $objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A2', $richText); ->setCellValue('A2', $richText);
$objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(-1); $objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(-1);
$objPHPExcel->getActiveSheet()->getStyle('A2') $objPHPExcel->getActiveSheet()->getStyle('A2')
->getAlignment() ->getAlignment()
->setWrapText(true); ->setWrapText(true);
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A3', $wizard->toRichTextObject($html3));
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A4', $wizard->toRichTextObject($html4));
// Rename worksheet // Rename worksheet
echo date('H:i:s') , " Rename worksheet" , EOL; echo date('H:i:s') , " Rename worksheet" , EOL;