public function PHPExcel_Writer_Excel2007_StringTable::writeRichText in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/StringTable.php \PHPExcel_Writer_Excel2007_StringTable::writeRichText()
* Write Rich Text * *
Parameters
PHPExcel_Shared_XMLWriter $objWriter XML Writer: * @param PHPExcel_RichText $pRichText Rich text * @param string $prefix Optional Namespace prefix * @throws PHPExcel_Writer_Exception
1 call to PHPExcel_Writer_Excel2007_StringTable::writeRichText()
- PHPExcel_Writer_Excel2007_StringTable::writeStringTable in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Writer/ Excel2007/ StringTable.php - * Write string table to XML format * *
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Writer/ Excel2007/ StringTable.php, line 150
Class
- PHPExcel_Writer_Excel2007_StringTable
- PHPExcel_Writer_Excel2007_StringTable
Code
public function writeRichText(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_RichText $pRichText = null, $prefix = NULL) {
if ($prefix !== NULL) {
$prefix .= ':';
}
// Loop through rich text elements
$elements = $pRichText
->getRichTextElements();
foreach ($elements as $element) {
// r
$objWriter
->startElement($prefix . 'r');
// rPr
if ($element instanceof PHPExcel_RichText_Run) {
// rPr
$objWriter
->startElement($prefix . 'rPr');
// rFont
$objWriter
->startElement($prefix . 'rFont');
$objWriter
->writeAttribute('val', $element
->getFont()
->getName());
$objWriter
->endElement();
// Bold
$objWriter
->startElement($prefix . 'b');
$objWriter
->writeAttribute('val', $element
->getFont()
->getBold() ? 'true' : 'false');
$objWriter
->endElement();
// Italic
$objWriter
->startElement($prefix . 'i');
$objWriter
->writeAttribute('val', $element
->getFont()
->getItalic() ? 'true' : 'false');
$objWriter
->endElement();
// Superscript / subscript
if ($element
->getFont()
->getSuperScript() || $element
->getFont()
->getSubScript()) {
$objWriter
->startElement($prefix . 'vertAlign');
if ($element
->getFont()
->getSuperScript()) {
$objWriter
->writeAttribute('val', 'superscript');
}
else {
if ($element
->getFont()
->getSubScript()) {
$objWriter
->writeAttribute('val', 'subscript');
}
}
$objWriter
->endElement();
}
// Strikethrough
$objWriter
->startElement($prefix . 'strike');
$objWriter
->writeAttribute('val', $element
->getFont()
->getStrikethrough() ? 'true' : 'false');
$objWriter
->endElement();
// Color
$objWriter
->startElement($prefix . 'color');
$objWriter
->writeAttribute('rgb', $element
->getFont()
->getColor()
->getARGB());
$objWriter
->endElement();
// Size
$objWriter
->startElement($prefix . 'sz');
$objWriter
->writeAttribute('val', $element
->getFont()
->getSize());
$objWriter
->endElement();
// Underline
$objWriter
->startElement($prefix . 'u');
$objWriter
->writeAttribute('val', $element
->getFont()
->getUnderline());
$objWriter
->endElement();
$objWriter
->endElement();
}
// t
$objWriter
->startElement($prefix . 't');
$objWriter
->writeAttribute('xml:space', 'preserve');
$objWriter
->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($element
->getText()));
$objWriter
->endElement();
$objWriter
->endElement();
}
}