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


PHP PHPExcel_Shared_Font::calculateColumnWidth方法代码示例

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


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

示例1: calculateColumnWidths

 /**
  * Calculate widths for auto-size columns
  *
  * @param  boolean  $calculateMergeCells  Calculate merge cell width
  * @return PHPExcel_Worksheet;
  */
 public function calculateColumnWidths($calculateMergeCells = false)
 {
     // initialize $autoSizes array
     $autoSizes = array();
     foreach ($this->getColumnDimensions() as $colDimension) {
         if ($colDimension->getAutoSize()) {
             $autoSizes[$colDimension->getColumnIndex()] = -1;
         }
     }
     // There is only something to do if there are some auto-size columns
     if (!empty($autoSizes)) {
         // build list of cells references that participate in a merge
         $isMergeCell = array();
         foreach ($this->getMergeCells() as $cells) {
             foreach (PHPExcel_Cell::extractAllCellReferencesInRange($cells) as $cellReference) {
                 $isMergeCell[$cellReference] = true;
             }
         }
         // loop through all cells in the worksheet
         foreach ($this->getCellCollection(false) as $cellID) {
             $cell = $this->getCell($cellID);
             if (isset($autoSizes[$this->_cellCollection->getCurrentColumn()])) {
                 // Determine width if cell does not participate in a merge
                 if (!isset($isMergeCell[$this->_cellCollection->getCurrentAddress()])) {
                     // Calculated value
                     // To formatted string
                     $cellValue = PHPExcel_Style_NumberFormat::toFormattedString($cell->getCalculatedValue(), $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode());
                     $autoSizes[$this->_cellCollection->getCurrentColumn()] = max((double) $autoSizes[$this->_cellCollection->getCurrentColumn()], (double) PHPExcel_Shared_Font::calculateColumnWidth($this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(), $cellValue, $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(), $this->getDefaultStyle()->getFont()));
                 }
             }
         }
         // adjust column widths
         foreach ($autoSizes as $columnIndex => $width) {
             if ($width == -1) {
                 $width = $this->getDefaultColumnDimension()->getWidth();
             }
             $this->getColumnDimension($columnIndex)->setWidth($width);
         }
     }
     return $this;
 }
开发者ID:andrelotto,项目名称:EmailMarketing,代码行数:47,代码来源:Worksheet.php

示例2: calculateColumnWidths

 /**
  * Calculate widths for auto-size columns
  * 
  * @param  boolean  $calculateMergeCells  Calculate merge cell width
  */
 public function calculateColumnWidths($calculateMergeCells = false)
 {
     $autoSizes = array();
     foreach ($this->getColumnDimensions() as $colDimension) {
         if ($colDimension->getAutoSize()) {
             $autoSizes[$colDimension->getColumnIndex()] = -1;
         }
     }
     foreach ($this->getCellCollection() as $cell) {
         if (isset($autoSizes[$cell->getColumn()])) {
             $cellValue = $cell->getCalculatedValue();
             foreach ($this->getMergeCells() as $cells) {
                 if ($cell->isInRange($cells) && !$calculateMergeCells) {
                     $cellValue = '';
                     // do not calculate merge cells
                 }
             }
             $autoSizes[$cell->getColumn()] = max((double) $autoSizes[$cell->getColumn()], (double) PHPExcel_Shared_Font::calculateColumnWidth($this->getStyle($cell->getCoordinate())->getFont()->getSize(), false, $cellValue));
         }
     }
     foreach ($autoSizes as $columnIndex => $width) {
         $this->getColumnDimension($columnIndex)->setWidth($width);
     }
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:29,代码来源:Worksheet.php

示例3: calculateColumnWidths

 /**
  * Calculate widths for auto-size columns
  *
  * @param  boolean  $calculateMergeCells  Calculate merge cell width
  * @return PHPExcel_Worksheet;
  */
 public function calculateColumnWidths($calculateMergeCells = false)
 {
     // initialize $autoSizes array
     $autoSizes = array();
     foreach ($this->getColumnDimensions() as $colDimension) {
         if ($colDimension->getAutoSize()) {
             $autoSizes[$colDimension->getColumnIndex()] = -1;
         }
     }
     // There is only something to do if there are some auto-size columns
     if (!empty($autoSizes)) {
         foreach ($this->getCellCollection(false) as $cell) {
             if (isset($autoSizes[$cell->getColumn()])) {
                 // Is merge cell?
                 $isMergeCell = false;
                 foreach ($this->getMergeCells() as $cells) {
                     if ($cell->isInRange($cells) && !$calculateMergeCells) {
                         $isMergeCell = true;
                         // do not calculate merge cells
                         break;
                     }
                 }
                 // Determine width
                 if (!$isMergeCell) {
                     // Calculated value
                     $cellValue = $cell->getCalculatedValue();
                     // To formatted string
                     $cellValue = PHPExcel_Style_NumberFormat::toFormattedString($cellValue, $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode());
                     $autoSizes[$cell->getColumn()] = max((double) $autoSizes[$cell->getColumn()], (double) PHPExcel_Shared_Font::calculateColumnWidth($this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(), $cellValue, $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(), $this->getDefaultStyle()->getFont()));
                 }
             }
         }
         // adjust column widths
         foreach ($autoSizes as $columnIndex => $width) {
             if ($width == -1) {
                 $width = $this->getDefaultColumnDimension()->getWidth();
             }
             $this->getColumnDimension($columnIndex)->setWidth($width);
         }
     }
     return $this;
 }
开发者ID:nvidela,项目名称:kimkelen,代码行数:48,代码来源:Worksheet.php

示例4: calculateColumnWidths

 /**
  * Calculate widths for auto-size columns
  */
 public function calculateColumnWidths()
 {
     $autoSizes = array();
     foreach ($this->getColumnDimensions() as $colDimension) {
         if ($colDimension->getAutoSize()) {
             $autoSizes[$colDimension->getColumnIndex()] = -1;
         }
     }
     foreach ($this->getCellCollection() as $cell) {
         if (isset($autoSizes[$cell->getColumn()])) {
             $autoSizes[$cell->getColumn()] = max($autoSizes[$cell->getColumn()], PHPExcel_Shared_Font::calculateColumnWidth($this->getStyle($cell->getCoordinate())->getFont()->getSize(), false, $cell->getCalculatedValue()));
         }
     }
     foreach ($autoSizes as $columnIndex => $width) {
         $this->getColumnDimension($columnIndex)->setWidth($width);
     }
 }
开发者ID:hostellerie,项目名称:nexpro,代码行数:20,代码来源:Worksheet.php


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