public function PHPExcel_Writer_Excel2007_Style::writeStyles in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Style.php \PHPExcel_Writer_Excel2007_Style::writeStyles()
* Write styles to XML format * *
Parameters
PHPExcel $pPHPExcel: * @return string XML Output * @throws PHPExcel_Writer_Exception
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Writer/ Excel2007/ Style.php, line 45
Class
- PHPExcel_Writer_Excel2007_Style
- PHPExcel_Writer_Excel2007_Style
Code
public function writeStyles(PHPExcel $pPHPExcel = null) {
// Create XML writer
$objWriter = null;
if ($this
->getParentWriter()
->getUseDiskCaching()) {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this
->getParentWriter()
->getDiskCachingDirectory());
}
else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
// XML header
$objWriter
->startDocument('1.0', 'UTF-8', 'yes');
// styleSheet
$objWriter
->startElement('styleSheet');
$objWriter
->writeAttribute('xml:space', 'preserve');
$objWriter
->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
// numFmts
$objWriter
->startElement('numFmts');
$objWriter
->writeAttribute('count', $this
->getParentWriter()
->getNumFmtHashTable()
->count());
// numFmt
for ($i = 0; $i < $this
->getParentWriter()
->getNumFmtHashTable()
->count(); ++$i) {
$this
->_writeNumFmt($objWriter, $this
->getParentWriter()
->getNumFmtHashTable()
->getByIndex($i), $i);
}
$objWriter
->endElement();
// fonts
$objWriter
->startElement('fonts');
$objWriter
->writeAttribute('count', $this
->getParentWriter()
->getFontHashTable()
->count());
// font
for ($i = 0; $i < $this
->getParentWriter()
->getFontHashTable()
->count(); ++$i) {
$this
->_writeFont($objWriter, $this
->getParentWriter()
->getFontHashTable()
->getByIndex($i));
}
$objWriter
->endElement();
// fills
$objWriter
->startElement('fills');
$objWriter
->writeAttribute('count', $this
->getParentWriter()
->getFillHashTable()
->count());
// fill
for ($i = 0; $i < $this
->getParentWriter()
->getFillHashTable()
->count(); ++$i) {
$this
->_writeFill($objWriter, $this
->getParentWriter()
->getFillHashTable()
->getByIndex($i));
}
$objWriter
->endElement();
// borders
$objWriter
->startElement('borders');
$objWriter
->writeAttribute('count', $this
->getParentWriter()
->getBordersHashTable()
->count());
// border
for ($i = 0; $i < $this
->getParentWriter()
->getBordersHashTable()
->count(); ++$i) {
$this
->_writeBorder($objWriter, $this
->getParentWriter()
->getBordersHashTable()
->getByIndex($i));
}
$objWriter
->endElement();
// cellStyleXfs
$objWriter
->startElement('cellStyleXfs');
$objWriter
->writeAttribute('count', 1);
// xf
$objWriter
->startElement('xf');
$objWriter
->writeAttribute('numFmtId', 0);
$objWriter
->writeAttribute('fontId', 0);
$objWriter
->writeAttribute('fillId', 0);
$objWriter
->writeAttribute('borderId', 0);
$objWriter
->endElement();
$objWriter
->endElement();
// cellXfs
$objWriter
->startElement('cellXfs');
$objWriter
->writeAttribute('count', count($pPHPExcel
->getCellXfCollection()));
// xf
foreach ($pPHPExcel
->getCellXfCollection() as $cellXf) {
$this
->_writeCellStyleXf($objWriter, $cellXf, $pPHPExcel);
}
$objWriter
->endElement();
// cellStyles
$objWriter
->startElement('cellStyles');
$objWriter
->writeAttribute('count', 1);
// cellStyle
$objWriter
->startElement('cellStyle');
$objWriter
->writeAttribute('name', 'Normal');
$objWriter
->writeAttribute('xfId', 0);
$objWriter
->writeAttribute('builtinId', 0);
$objWriter
->endElement();
$objWriter
->endElement();
// dxfs
$objWriter
->startElement('dxfs');
$objWriter
->writeAttribute('count', $this
->getParentWriter()
->getStylesConditionalHashTable()
->count());
// dxf
for ($i = 0; $i < $this
->getParentWriter()
->getStylesConditionalHashTable()
->count(); ++$i) {
$this
->_writeCellStyleDxf($objWriter, $this
->getParentWriter()
->getStylesConditionalHashTable()
->getByIndex($i)
->getStyle());
}
$objWriter
->endElement();
// tableStyles
$objWriter
->startElement('tableStyles');
$objWriter
->writeAttribute('defaultTableStyle', 'TableStyleMedium9');
$objWriter
->writeAttribute('defaultPivotStyle', 'PivotTableStyle1');
$objWriter
->endElement();
$objWriter
->endElement();
// Return
return $objWriter
->getData();
}