56 $objWriter->startDocument(
'1.0',
'UTF-8',
'yes');
59 $objWriter->startElement(
'styleSheet');
60 $objWriter->writeAttribute(
'xml:space',
'preserve');
61 $objWriter->writeAttribute(
'xmlns',
'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
64 $objWriter->startElement(
'numFmts');
65 $objWriter->writeAttribute(
'count', $this->
getParentWriter()->getNumFmtHashTable()->count());
68 for ($i = 0; $i < $this->
getParentWriter()->getNumFmtHashTable()->count(); ++$i) {
72 $objWriter->endElement();
75 $objWriter->startElement(
'fonts');
76 $objWriter->writeAttribute(
'count', $this->
getParentWriter()->getFontHashTable()->count());
79 for ($i = 0; $i < $this->
getParentWriter()->getFontHashTable()->count(); ++$i) {
83 $objWriter->endElement();
86 $objWriter->startElement(
'fills');
87 $objWriter->writeAttribute(
'count', $this->
getParentWriter()->getFillHashTable()->count());
90 for ($i = 0; $i < $this->
getParentWriter()->getFillHashTable()->count(); ++$i) {
94 $objWriter->endElement();
97 $objWriter->startElement(
'borders');
98 $objWriter->writeAttribute(
'count', $this->
getParentWriter()->getBordersHashTable()->count());
101 for ($i = 0; $i < $this->
getParentWriter()->getBordersHashTable()->count(); ++$i) {
105 $objWriter->endElement();
108 $objWriter->startElement(
'cellStyleXfs');
109 $objWriter->writeAttribute(
'count', 1);
112 $objWriter->startElement(
'xf');
113 $objWriter->writeAttribute(
'numFmtId', 0);
114 $objWriter->writeAttribute(
'fontId', 0);
115 $objWriter->writeAttribute(
'fillId', 0);
116 $objWriter->writeAttribute(
'borderId', 0);
117 $objWriter->endElement();
119 $objWriter->endElement();
122 $objWriter->startElement(
'cellXfs');
123 $objWriter->writeAttribute(
'count', count($pPHPExcel->getCellXfCollection()));
126 foreach ($pPHPExcel->getCellXfCollection() as $cellXf) {
130 $objWriter->endElement();
133 $objWriter->startElement(
'cellStyles');
134 $objWriter->writeAttribute(
'count', 1);
137 $objWriter->startElement(
'cellStyle');
138 $objWriter->writeAttribute(
'name',
'Normal');
139 $objWriter->writeAttribute(
'xfId', 0);
140 $objWriter->writeAttribute(
'builtinId', 0);
141 $objWriter->endElement();
143 $objWriter->endElement();
146 $objWriter->startElement(
'dxfs');
147 $objWriter->writeAttribute(
'count', $this->
getParentWriter()->getStylesConditionalHashTable()->count());
150 for ($i = 0; $i < $this->
getParentWriter()->getStylesConditionalHashTable()->count(); ++$i) {
154 $objWriter->endElement();
157 $objWriter->startElement(
'tableStyles');
158 $objWriter->writeAttribute(
'defaultTableStyle',
'TableStyleMedium9');
159 $objWriter->writeAttribute(
'defaultPivotStyle',
'PivotTableStyle1');
160 $objWriter->endElement();
162 $objWriter->endElement();
165 return $objWriter->getData();
198 $objWriter->startElement(
'fill');
201 $objWriter->startElement(
'gradientFill');
202 $objWriter->writeAttribute(
'type', $pFill->getFillType());
203 $objWriter->writeAttribute(
'degree', $pFill->getRotation());
206 $objWriter->startElement(
'stop');
207 $objWriter->writeAttribute(
'position',
'0');
210 $objWriter->startElement(
'color');
211 $objWriter->writeAttribute(
'rgb', $pFill->getStartColor()->getARGB());
212 $objWriter->endElement();
214 $objWriter->endElement();
217 $objWriter->startElement(
'stop');
218 $objWriter->writeAttribute(
'position',
'1');
221 $objWriter->startElement(
'color');
222 $objWriter->writeAttribute(
'rgb', $pFill->getEndColor()->getARGB());
223 $objWriter->endElement();
225 $objWriter->endElement();
227 $objWriter->endElement();
229 $objWriter->endElement();
242 $objWriter->startElement(
'fill');
245 $objWriter->startElement(
'patternFill');
246 $objWriter->writeAttribute(
'patternType', $pFill->getFillType());
249 $objWriter->startElement(
'fgColor');
250 $objWriter->writeAttribute(
'rgb', $pFill->getStartColor()->getARGB());
251 $objWriter->endElement();
254 $objWriter->startElement(
'bgColor');
255 $objWriter->writeAttribute(
'rgb', $pFill->getEndColor()->getARGB());
256 $objWriter->endElement();
258 $objWriter->endElement();
260 $objWriter->endElement();
273 $objWriter->startElement(
'font');
276 $objWriter->startElement(
'name');
277 $objWriter->writeAttribute(
'val', $pFont->getName());
278 $objWriter->endElement();
281 $objWriter->startElement(
'sz');
282 $objWriter->writeAttribute(
'val', $pFont->getSize());
283 $objWriter->endElement();
288 $objWriter->startElement(
'b');
289 $objWriter->writeAttribute(
'val', $pFont->getBold() ?
'1' :
'0');
290 $objWriter->endElement();
293 $objWriter->startElement(
'i');
294 $objWriter->writeAttribute(
'val', $pFont->getItalic() ?
'1' :
'0');
295 $objWriter->endElement();
298 if ($pFont->getSuperScript() || $pFont->getSubScript()) {
299 $objWriter->startElement(
'vertAlign');
300 if ($pFont->getSuperScript()) {
301 $objWriter->writeAttribute(
'val',
'superscript');
302 }
else if ($pFont->getSubScript()) {
303 $objWriter->writeAttribute(
'val',
'subscript');
305 $objWriter->endElement();
309 $objWriter->startElement(
'u');
310 $objWriter->writeAttribute(
'val', $pFont->getUnderline());
311 $objWriter->endElement();
314 $objWriter->startElement(
'strike');
315 $objWriter->writeAttribute(
'val', $pFont->getStrikethrough() ?
'1' :
'0');
316 $objWriter->endElement();
319 $objWriter->startElement(
'color');
320 $objWriter->writeAttribute(
'rgb', $pFont->getColor()->getARGB());
321 $objWriter->endElement();
323 $objWriter->endElement();
336 $objWriter->startElement(
'border');
338 switch ($pBorders->getDiagonalDirection()) {
340 $objWriter->writeAttribute(
'diagonalUp',
'true');
341 $objWriter->writeAttribute(
'diagonalDown',
'false');
344 $objWriter->writeAttribute(
'diagonalUp',
'false');
345 $objWriter->writeAttribute(
'diagonalDown',
'true');
348 $objWriter->writeAttribute(
'diagonalUp',
'true');
349 $objWriter->writeAttribute(
'diagonalDown',
'true');
355 $this->
_writeBorderPr($objWriter,
'right', $pBorders->getRight());
357 $this->
_writeBorderPr($objWriter,
'bottom', $pBorders->getBottom());
358 $this->
_writeBorderPr($objWriter,
'diagonal', $pBorders->getDiagonal());
359 $objWriter->endElement();
373 $objWriter->startElement(
'xf');
374 $objWriter->writeAttribute(
'xfId', 0);
375 $objWriter->writeAttribute(
'fontId', (
int)$this->
getParentWriter()->getFontHashTable()->getIndexForHashCode($pStyle->getFont()->getHashCode()));
377 if ($pStyle->getNumberFormat()->getBuiltInFormatCode() ===
false) {
378 $objWriter->writeAttribute(
'numFmtId', (
int)($this->
getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($pStyle->getNumberFormat()->getHashCode()) + 164) );
380 $objWriter->writeAttribute(
'numFmtId', (
int)$pStyle->getNumberFormat()->getBuiltInFormatCode());
383 $objWriter->writeAttribute(
'fillId', (
int)$this->
getParentWriter()->getFillHashTable()->getIndexForHashCode($pStyle->getFill()->getHashCode()));
384 $objWriter->writeAttribute(
'borderId', (
int)$this->
getParentWriter()->getBordersHashTable()->getIndexForHashCode($pStyle->getBorders()->getHashCode()));
387 $objWriter->writeAttribute(
'applyFont', ($pPHPExcel->getDefaultStyle()->getFont()->getHashCode() != $pStyle->getFont()->getHashCode()) ?
'1' :
'0');
388 $objWriter->writeAttribute(
'applyNumberFormat', ($pPHPExcel->getDefaultStyle()->getNumberFormat()->getHashCode() != $pStyle->getNumberFormat()->getHashCode()) ?
'1' :
'0');
389 $objWriter->writeAttribute(
'applyFill', ($pPHPExcel->getDefaultStyle()->getFill()->getHashCode() != $pStyle->getFill()->getHashCode()) ?
'1' :
'0');
390 $objWriter->writeAttribute(
'applyBorder', ($pPHPExcel->getDefaultStyle()->getBorders()->getHashCode() != $pStyle->getBorders()->getHashCode()) ?
'1' :
'0');
391 $objWriter->writeAttribute(
'applyAlignment', ($pPHPExcel->getDefaultStyle()->getAlignment()->getHashCode() != $pStyle->getAlignment()->getHashCode()) ?
'1' :
'0');
393 $objWriter->writeAttribute(
'applyProtection',
'true');
397 $objWriter->startElement(
'alignment');
398 $objWriter->writeAttribute(
'horizontal', $pStyle->getAlignment()->getHorizontal());
399 $objWriter->writeAttribute(
'vertical', $pStyle->getAlignment()->getVertical());
402 if ($pStyle->getAlignment()->getTextRotation() >= 0) {
403 $textRotation = $pStyle->getAlignment()->getTextRotation();
404 }
else if ($pStyle->getAlignment()->getTextRotation() < 0) {
405 $textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
408 $objWriter->writeAttribute(
'textRotation', $textRotation);
409 $objWriter->writeAttribute(
'wrapText', ($pStyle->getAlignment()->getWrapText() ?
'true' :
'false'));
410 $objWriter->writeAttribute(
'shrinkToFit', ($pStyle->getAlignment()->getShrinkToFit() ?
'true' :
'false'));
412 if ($pStyle->getAlignment()->getIndent() > 0) {
413 $objWriter->writeAttribute(
'indent', $pStyle->getAlignment()->getIndent());
415 $objWriter->endElement();
419 $objWriter->startElement(
'protection');
426 $objWriter->endElement();
429 $objWriter->endElement();
442 $objWriter->startElement(
'dxf');
445 $this->
_writeFont($objWriter, $pStyle->getFont());
448 $this->
_writeNumFmt($objWriter, $pStyle->getNumberFormat());
451 $this->
_writeFill($objWriter, $pStyle->getFill());
454 $objWriter->startElement(
'alignment');
455 $objWriter->writeAttribute(
'horizontal', $pStyle->getAlignment()->getHorizontal());
456 $objWriter->writeAttribute(
'vertical', $pStyle->getAlignment()->getVertical());
459 if ($pStyle->getAlignment()->getTextRotation() >= 0) {
460 $textRotation = $pStyle->getAlignment()->getTextRotation();
461 }
else if ($pStyle->getAlignment()->getTextRotation() < 0) {
462 $textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
465 $objWriter->writeAttribute(
'textRotation', $textRotation);
466 $objWriter->endElement();
473 $objWriter->startElement(
'protection');
480 $objWriter->endElement();
483 $objWriter->endElement();
498 $objWriter->startElement($pName);
499 $objWriter->writeAttribute(
'style', $pBorder->getBorderStyle());
502 $objWriter->startElement(
'color');
503 $objWriter->writeAttribute(
'rgb', $pBorder->getColor()->getARGB());
504 $objWriter->endElement();
506 $objWriter->endElement();
521 $formatCode = $pNumberFormat->getFormatCode();
524 $objWriter->startElement(
'numFmt');
525 $objWriter->writeAttribute(
'numFmtId', ($pId + 164));
526 $objWriter->writeAttribute(
'formatCode', $formatCode);
527 $objWriter->endElement();
539 $aStyles = $pPHPExcel->getCellXfCollection();
556 $sheetCount = $pPHPExcel->getSheetCount();
557 for ($i = 0; $i < $sheetCount; ++$i) {
558 foreach ($pPHPExcel->getSheet($i)->getConditionalStylesCollection() as $conditionalStyles) {
559 foreach ($conditionalStyles as $conditionalStyle) {
560 $aStyles[] = $conditionalStyle;
591 foreach ($aStyles as $style) {
592 if (!array_key_exists($style->getFill()->getHashCode(), $aFills)) {
593 $aFills[ $style->getFill()->getHashCode() ] = $style->getFill();
613 foreach ($aStyles as $style) {
614 if (!array_key_exists($style->getFont()->getHashCode(), $aFonts)) {
615 $aFonts[ $style->getFont()->getHashCode() ] = $style->getFont();
635 foreach ($aStyles as $style) {
636 if (!array_key_exists($style->getBorders()->getHashCode(), $aBorders)) {
637 $aBorders[ $style->getBorders()->getHashCode() ] = $style->getBorders();
657 foreach ($aStyles as $style) {
658 if ($style->getNumberFormat()->getBuiltInFormatCode() ===
false && !array_key_exists($style->getNumberFormat()->getHashCode(), $aNumFmts)) {
659 $aNumFmts[ $style->getNumberFormat()->getHashCode() ] = $style->getNumberFormat();