示例#1
0
 /**
  * Write Bubble Chart Details
  *
  * @param  DataSeriesValues $plotSeriesValues
  * @param  \PHPExcel\Shared\XMLWriter $objWriter XML Writer
  *
  * @throws  \PHPExcel\Writer\Exception
  */
 private function writeBubbles($plotSeriesValues, $objWriter)
 {
     if (is_null($plotSeriesValues)) {
         return;
     }
     $objWriter->startElement('c:bubbleSize');
     $objWriter->startElement('c:numLit');
     $objWriter->startElement('c:formatCode');
     $objWriter->writeRawData('General');
     $objWriter->endElement();
     $objWriter->startElement('c:ptCount');
     $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount());
     $objWriter->endElement();
     $dataValues = $plotSeriesValues->getDataValues();
     if (!empty($dataValues)) {
         if (is_array($dataValues)) {
             foreach ($dataValues as $plotSeriesKey => $plotSeriesValue) {
                 $objWriter->startElement('c:pt');
                 $objWriter->writeAttribute('idx', $plotSeriesKey);
                 $objWriter->startElement('c:v');
                 $objWriter->writeRawData(1);
                 $objWriter->endElement();
                 $objWriter->endElement();
             }
         }
     }
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->startElement('c:bubble3D');
     $objWriter->writeAttribute('val', 0);
     $objWriter->endElement();
 }
示例#2
0
 /**
  * Write Defined Name for PrintTitles
  *
  * @param     \PHPExcel\Shared\XMLWriter    $objWriter         XML Writer
  * @param     \PHPExcel\Worksheet            $pSheet
  * @param     int                            $pSheetId
  * @throws     \PHPExcel\Writer\Exception
  */
 private function writeDefinedNameForPrintArea(\PHPExcel\Shared\XMLWriter $objWriter, \PHPExcel\Worksheet $pSheet = null, $pSheetId = 0)
 {
     // definedName for PrintArea
     if ($pSheet->getPageSetup()->isPrintAreaSet()) {
         $objWriter->startElement('definedName');
         $objWriter->writeAttribute('name', '_xlnm.Print_Area');
         $objWriter->writeAttribute('localSheetId', $pSheetId);
         // Setting string
         $settingString = '';
         // Print area
         $printArea = \PHPExcel\Cell::splitRange($pSheet->getPageSetup()->getPrintArea());
         $chunks = array();
         foreach ($printArea as $printAreaRect) {
             $printAreaRect[0] = \PHPExcel\Cell::absoluteReference($printAreaRect[0]);
             $printAreaRect[1] = \PHPExcel\Cell::absoluteReference($printAreaRect[1]);
             $chunks[] = '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . implode(':', $printAreaRect);
         }
         $objWriter->writeRawData(implode(',', $chunks));
         $objWriter->endElement();
     }
 }
示例#3
0
 /**
  * Write Rich Text
  *
  * @param     \PHPExcel\Shared\XMLWriter    $objWriter         XML Writer
  * @param     string|\PHPExcel\RichText    $pRichText        text string or Rich text
  * @param     string                        $prefix            Optional Namespace prefix
  * @throws     \PHPExcel\Writer\Exception
  */
 public function writeRichTextForCharts(\PHPExcel\Shared\XMLWriter $objWriter = null, $pRichText = null, $prefix = null)
 {
     if (!$pRichText instanceof \PHPExcel\RichText) {
         $textRun = $pRichText;
         $pRichText = new \PHPExcel\RichText();
         $pRichText->createTextRun($textRun);
     }
     if ($prefix !== null) {
         $prefix .= ':';
     }
     // Loop through rich text elements
     $elements = $pRichText->getRichTextElements();
     foreach ($elements as $element) {
         // r
         $objWriter->startElement($prefix . 'r');
         // rPr
         $objWriter->startElement($prefix . 'rPr');
         // Bold
         $objWriter->writeAttribute('b', $element->getFont()->getBold() ? 1 : 0);
         // Italic
         $objWriter->writeAttribute('i', $element->getFont()->getItalic() ? 1 : 0);
         // Underline
         $underlineType = $element->getFont()->getUnderline();
         switch ($underlineType) {
             case 'single':
                 $underlineType = 'sng';
                 break;
             case 'double':
                 $underlineType = 'dbl';
                 break;
         }
         $objWriter->writeAttribute('u', $underlineType);
         // Strikethrough
         $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough() ? 'sngStrike' : 'noStrike');
         // rFont
         $objWriter->startElement($prefix . 'latin');
         $objWriter->writeAttribute('typeface', $element->getFont()->getName());
         $objWriter->endElement();
         // Superscript / subscript
         //                    if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
         //                        $objWriter->startElement($prefix.'vertAlign');
         //                        if ($element->getFont()->getSuperScript()) {
         //                            $objWriter->writeAttribute('val', 'superscript');
         //                        } elseif ($element->getFont()->getSubScript()) {
         //                            $objWriter->writeAttribute('val', 'subscript');
         //                        }
         //                        $objWriter->endElement();
         //                    }
         //
         $objWriter->endElement();
         // t
         $objWriter->startElement($prefix . 't');
         //                    $objWriter->writeAttribute('xml:space', 'preserve');    //    Excel2010 accepts, Excel2007 complains
         $objWriter->writeRawData(\PHPExcel\Shared\StringHelper::controlCharacterPHP2OOXML($element->getText()));
         $objWriter->endElement();
         $objWriter->endElement();
     }
 }