You are here

public static function PHPExcel_Shared_Drawing::cellDimensionToPixels in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/Drawing.php \PHPExcel_Shared_Drawing::cellDimensionToPixels()

* Convert column width from (intrinsic) Excel units to pixels * *

Parameters

float $pValue Value in cell dimension: * @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook * @return int Value in pixels

2 calls to PHPExcel_Shared_Drawing::cellDimensionToPixels()
PHPExcel_Shared_Excel5::sizeCol in vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/Excel5.php
* Get the width of a column in pixels. We use the relationship y = ceil(7x) where * x is the width in intrinsic Excel units (measuring width in number of normal characters) * This holds for Arial 10 * *
PHPExcel_Writer_HTML::buildCSS in vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/HTML.php
* Build CSS styles * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/Drawing.php, line 99

Class

PHPExcel_Shared_Drawing
PHPExcel_Shared_Drawing

Code

public static function cellDimensionToPixels($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {

  // Font name and size
  $name = $pDefaultFont
    ->getName();
  $size = $pDefaultFont
    ->getSize();
  if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {

    // Exact width can be determined
    $colWidth = $pValue * PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'] / PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'];
  }
  else {

    // We don't have data for this particular font and size, use approximation by
    // extrapolating from Calibri 11
    $colWidth = $pValue * $size * PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / 11;
  }

  // Round pixels to closest integer
  $colWidth = (int) round($colWidth);
  return $colWidth;
}