当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPExcel_Worksheet::getChartCollection方法代码示例

本文整理汇总了PHP中PHPExcel_Worksheet::getChartCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Worksheet::getChartCollection方法的具体用法?PHP PHPExcel_Worksheet::getChartCollection怎么用?PHP PHPExcel_Worksheet::getChartCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPExcel_Worksheet的用法示例。


在下文中一共展示了PHPExcel_Worksheet::getChartCollection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _writeChartInCell

 /**
  * Generate chart tag in cell
  *
  * @param	PHPExcel_Worksheet	$pSheet			PHPExcel_Worksheet
  * @param	string				$coordinates	Cell coordinates
  * @return	string
  * @throws	PHPExcel_Writer_Exception
  */
 private function _writeChartInCell(PHPExcel_Worksheet $pSheet, $coordinates)
 {
     // Construct HTML
     $html = '';
     // Write charts
     foreach ($pSheet->getChartCollection() as $chart) {
         if ($chart instanceof PHPExcel_Chart) {
             $chartCoordinates = $chart->getTopLeftPosition();
             if ($chartCoordinates['cell'] == $coordinates) {
                 $chartFileName = PHPExcel_Shared_File::sys_get_temp_dir() . '/' . uniqid() . '.png';
                 if (!$chart->render($chartFileName)) {
                     return;
                 }
                 $html .= PHP_EOL;
                 $imageDetails = getimagesize($chartFileName);
                 if ($fp = fopen($chartFileName, "rb", 0)) {
                     $picture = fread($fp, filesize($chartFileName));
                     fclose($fp);
                     // base64 encode the binary data, then break it
                     // into chunks according to RFC 2045 semantics
                     $base64 = chunk_split(base64_encode($picture));
                     $imageData = 'data:' . $imageDetails['mime'] . ';base64,' . $base64;
                     $html .= '<div style="position: relative;">';
                     $html .= '<img style="position: absolute; z-index: 1; left: ' . $chartCoordinates['xOffset'] . 'px; top: ' . $chartCoordinates['yOffset'] . 'px; width: ' . $imageDetails[0] . 'px; height: ' . $imageDetails[1] . 'px;" src="' . $imageData . '" border="0" />' . PHP_EOL;
                     $html .= '</div>';
                     unlink($chartFileName);
                 }
             }
         }
     }
     // Return
     return $html;
 }
开发者ID:adit-gudhel,项目名称:simpus-dev,代码行数:41,代码来源:HTML.php

示例2: writeWorksheetRelationships

 /**
  * Write worksheet relationships to XML format
  *
  * Numbering is as follows:
  * 	rId1 				- Drawings
  *  rId_hyperlink_x 	- Hyperlinks
  *
  * @param 	PHPExcel_Worksheet	$pWorksheet
  * @param 	int					$pWorksheetId
  * @param	boolean				$includeCharts	Flag indicating if we should write charts
  * @return 	string 				XML Output
  * @throws 	PHPExcel_Writer_Exception
  */
 public function writeWorksheetRelationships(PHPExcel_Worksheet $pWorksheet = null, $pWorksheetId = 1, $includeCharts = FALSE)
 {
     // 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');
     // Relationships
     $objWriter->startElement('Relationships');
     $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
     // Write drawing relationships?
     $d = 0;
     if ($includeCharts) {
         $charts = $pWorksheet->getChartCollection();
     } else {
         $charts = array();
     }
     if ($pWorksheet->getDrawingCollection()->count() > 0 || count($charts) > 0) {
         $this->_writeRelationship($objWriter, ++$d, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing', '../drawings/drawing' . $pWorksheetId . '.xml');
     }
     // Write chart relationships?
     //			$chartCount = 0;
     //			$charts = $pWorksheet->getChartCollection();
     //			echo 'Chart Rels: ' , count($charts) , '<br />';
     //			if (count($charts) > 0) {
     //				foreach($charts as $chart) {
     //					$this->_writeRelationship(
     //						$objWriter,
     //						++$d,
     //						'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
     //						'../charts/chart' . ++$chartCount . '.xml'
     //					);
     //				}
     //			}
     //
     // Write hyperlink relationships?
     $i = 1;
     foreach ($pWorksheet->getHyperlinkCollection() as $hyperlink) {
         if (!$hyperlink->isInternal()) {
             $this->_writeRelationship($objWriter, '_hyperlink_' . $i, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External');
             ++$i;
         }
     }
     // Write comments relationship?
     $i = 1;
     if (count($pWorksheet->getComments()) > 0) {
         $this->_writeRelationship($objWriter, '_comments_vml' . $i, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing', '../drawings/vmlDrawing' . $pWorksheetId . '.vml');
         $this->_writeRelationship($objWriter, '_comments' . $i, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments', '../comments' . $pWorksheetId . '.xml');
     }
     // Write header/footer relationship?
     $i = 1;
     if (count($pWorksheet->getHeaderFooter()->getImages()) > 0) {
         $this->_writeRelationship($objWriter, '_headerfooter_vml' . $i, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing', '../drawings/vmlDrawingHF' . $pWorksheetId . '.vml');
     }
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
开发者ID:jonpetersen,项目名称:PHTC,代码行数:75,代码来源:Rels.php

示例3: _writeDrawings

 /**
  * Write Drawings
  *
  * @param	PHPExcel_Shared_XMLWriter	$objWriter		XML Writer
  * @param	PHPExcel_Worksheet			$pSheet			Worksheet
  * @param	boolean						$includeCharts	Flag indicating if we should include drawing details for charts
  * @throws	PHPExcel_Writer_Exception
  */
 private function _writeDrawings(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $includeCharts = FALSE)
 {
     $chartCount = $includeCharts ? $pSheet->getChartCollection()->count() : 0;
     // If sheet contains drawings, add the relationships
     if ($pSheet->getDrawingCollection()->count() > 0 || $chartCount > 0) {
         $objWriter->startElement('drawing');
         $objWriter->writeAttribute('r:id', 'rId1');
         $objWriter->endElement();
     }
 }
开发者ID:YellowYellow,项目名称:Graduation-Project,代码行数:18,代码来源:Worksheet.php

示例4: _extendRowsForChartsAndImages

 private function _extendRowsForChartsAndImages(PHPExcel_Worksheet $pSheet, $row)
 {
     $rowMax = $row;
     $colMax = 'A';
     if ($this->_includeCharts) {
         foreach ($pSheet->getChartCollection() as $chart) {
             if ($chart instanceof PHPExcel_Chart) {
                 $chartCoordinates = $chart->getTopLeftPosition();
                 $chartTL = PHPExcel_Cell::coordinateFromString($chartCoordinates['cell']);
                 $chartCol = PHPExcel_Cell::columnIndexFromString($chartTL[0]);
                 if ($chartTL[1] > $rowMax) {
                     $rowMax = $chartTL[1];
                     if ($chartCol > PHPExcel_Cell::columnIndexFromString($colMax)) {
                         $colMax = $chartTL[0];
                     }
                 }
             }
         }
     }
     foreach ($pSheet->getDrawingCollection() as $drawing) {
         if ($drawing instanceof PHPExcel_Worksheet_Drawing) {
             $imageTL = PHPExcel_Cell::coordinateFromString($drawing->getCoordinates());
             $imageCol = PHPExcel_Cell::columnIndexFromString($imageTL[0]);
             if ($imageTL[1] > $rowMax) {
                 $rowMax = $imageTL[1];
                 if ($imageCol > PHPExcel_Cell::columnIndexFromString($colMax)) {
                     $colMax = $imageTL[0];
                 }
             }
         }
     }
     $html = '';
     $colMax++;
     while ($row < $rowMax) {
         $html .= '<tr>';
         for ($col = 'A'; $col != $colMax; ++$col) {
             $html .= '<td>';
             $html .= $this->_writeImageInCell($pSheet, $col . $row);
             if ($this->_includeCharts) {
                 $html .= $this->_writeChartInCell($pSheet, $col . $row);
             }
             $html .= '</td>';
         }
         ++$row;
         $html .= '</tr>';
     }
     return $html;
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:48,代码来源:HTML.php


注:本文中的PHPExcel_Worksheet::getChartCollection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。