My very first example of rich text
generated from html markup
This block contains an italicized word;
while this block uses an underline.
I want to eat healthy food pizza.
';
$html2 = '
100°C is a hot temperature
10°F is cold
';
$html3 = '23 equals 8';
$html4 = 'H2SO4 is the chemical formula for Sulphuric acid';
$html5 = 'bold, italic, bold+italic';
$wizard = new HtmlHelper();
$richText = $wizard->toRichTextObject($html1);
$spreadsheet->getActiveSheet()
->setCellValue('A1', $richText);
$spreadsheet->getActiveSheet()
->getColumnDimension('A')
->setWidth(48);
$spreadsheet->getActiveSheet()
->getRowDimension(1)
->setRowHeight(-1);
$spreadsheet->getActiveSheet()->getStyle('A1')
->getAlignment()
->setWrapText(true);
$richText = $wizard->toRichTextObject($html2);
$spreadsheet->getActiveSheet()
->setCellValue('A2', $richText);
$spreadsheet->getActiveSheet()
->getRowDimension(1)
->setRowHeight(-1);
$spreadsheet->getActiveSheet()
->getStyle('A2')
->getAlignment()
->setWrapText(true);
$spreadsheet->setActiveSheetIndex(0)
->setCellValue('A3', $wizard->toRichTextObject($html3));
$spreadsheet->setActiveSheetIndex(0)
->setCellValue('A4', $wizard->toRichTextObject($html4));
$spreadsheet->setActiveSheetIndex(0)
->setCellValue('A5', $wizard->toRichTextObject($html5));
// Rename worksheet
$helper->log('Rename worksheet');
$spreadsheet->getActiveSheet()
->setTitle('Rich Text Examples');
// Save
$helper->write($spreadsheet, __FILE__);