Improve logic
This commit is contained in:
parent
4f0e72c4e4
commit
d53be7bd2b
@ -141,15 +141,13 @@ class Worksheet
|
||||
*/
|
||||
public function autoSetWidth($cell, $style, $zeroBasedIndex)
|
||||
{
|
||||
$size = strlen($cell->getValue()) ?? 1;//use 1 as length if cell empty
|
||||
$size *= (float)($style->getFontSize() ?? 10);
|
||||
$size = 1 + strlen($cell->getValue());//ensure we have at least 1 space
|
||||
$size *= $style->isFontBold() ? 1.2 : 1.0;
|
||||
if ($this->getWidthCalculation() == Worksheet::W_FIXED) {
|
||||
$total = array_sum($this->getColumnWidths());
|
||||
$total = $total ?: $size;
|
||||
$size = ($size / $total) * $this->getFixedSheetWidth();
|
||||
}
|
||||
$size /= 10;
|
||||
$this->setMaxColumnWidth($zeroBasedIndex, $size);
|
||||
}
|
||||
|
||||
|
@ -286,6 +286,7 @@ class WorksheetManager implements WorksheetManagerInterface
|
||||
$widths = $worksheet->getColumnWidths();
|
||||
//todo: this may not be adequate for multiple worksheets
|
||||
foreach ($widths as $i => $width){
|
||||
//this is a rough equivalent based on pixel density
|
||||
$win = round($width / 9.6, 2);//convert to inches
|
||||
$colNo = $i + 1;
|
||||
$style .= '<style:style style:name="co'.$colNo.
|
||||
|
Loading…
x
Reference in New Issue
Block a user