public static function PHPExcel_Shared_Font::getDefaultColumnWidthByFont in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/Font.php \PHPExcel_Shared_Font::getDefaultColumnWidthByFont()
* Get the effective column width for columns without a column dimension or column with width -1 * For example, for Calibri 11 this is 9.140625 (64 px) * *
Parameters
PHPExcel_Style_Font $font The workbooks default font: * @param boolean $pPixels true = return column width in pixels, false = return in OOXML units * @return mixed Column width
2 calls to PHPExcel_Shared_Font::getDefaultColumnWidthByFont()
- 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_Excel5_Worksheet::close in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Writer/ Excel5/ Worksheet.php - * Add data to the beginning of the workbook (note the reverse order) * and to the end of the workbook. * * @access public *
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ Font.php, line 571
Class
- PHPExcel_Shared_Font
- PHPExcel_Shared_Font
Code
public static function getDefaultColumnWidthByFont(PHPExcel_Style_Font $font, $pPixels = false) {
if (isset(self::$defaultColumnWidths[$font
->getName()][$font
->getSize()])) {
// Exact width can be determined
$columnWidth = $pPixels ? self::$defaultColumnWidths[$font
->getName()][$font
->getSize()]['px'] : self::$defaultColumnWidths[$font
->getName()][$font
->getSize()]['width'];
}
else {
// We don't have data for this particular font and size, use approximation by
// extrapolating from Calibri 11
$columnWidth = $pPixels ? self::$defaultColumnWidths['Calibri'][11]['px'] : self::$defaultColumnWidths['Calibri'][11]['width'];
$columnWidth = $columnWidth * $font
->getSize() / 11;
// Round pixels to closest integer
if ($pPixels) {
$columnWidth = (int) round($columnWidth);
}
}
return $columnWidth;
}