update colWidth function

This commit is contained in:
willkensonh 2018-10-12 09:34:19 +11:00
parent bbd9f66428
commit 61b2480cc1
2 changed files with 8 additions and 26 deletions

View File

@ -127,10 +127,10 @@ class Worksheet
* @param float $width
* @throws IOException
*/
public function setColWidth(string $col, float $width)
public function setColWidth(int $colFrom, int $colTo, float $width)
{
$this->throwIfSheetFilePointerIsAlreadyCreated();
$this->colWidths[$col] = $width;
$this->colWidths[] = [$colFrom,$colTo,$width];
}
/**
@ -165,16 +165,6 @@ class Worksheet
$this->merges[] = $leftCell . ':' . $rightCell;
}
/**
* remove merged cell reference.
* @param string $leftCell
* @param string $rightCell
*/
public function unMergeCells(string $leftCell, string $rightCell)
{
$this->merges = array_diff($this->merges,[$leftCell . ':' . $rightCell]);
}
/**
* used by WorksheetManager to get default row height and width xml to inject into worksheet xml file
* @return string
@ -200,8 +190,8 @@ class Worksheet
return '';
}
$xml = '<cols>';
foreach ($this->colWidths as $col => $width) {
$xml .= '<col min="'.$col.'" max="'.$col.'" width="'.$width.'" style="1" customWidth="1"/>'; //style and customWidth may be unnecessary ??
foreach ($this->colWidths as $entry) {
$xml .= '<col min="'.$entry[0].'" max="'.$entry[1].'" width="'.$entry[2].'" style="1" customWidth="1"/>'; //style and customWidth may be unnecessary ??
}
$xml .= '</cols>';
return $xml;

View File

@ -187,13 +187,14 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
}
/**
* @param string $col
* @param string $colFrom
* @param string $colTo
* @param float $width
* @throws \Box\Spout\Common\Exception\IOException
*/
public function setColWidth(string $col, float $width)
public function setColWidth(int $colFrom, int $colTo, float $width)
{
$this->workbookManager->getCurrentWorksheet()->setColWidth($col, $width);
$this->workbookManager->getCurrentWorksheet()->setColWidth($colFrom, $colTo, $width);
}
/**
@ -222,13 +223,4 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
{
$this->workbookManager->getCurrentWorksheet()->mergeCells($leftCell,$rightCell);
}
/**
* @param string $leftCell
* @param string $rightCell
*/
public function unMergeCells(string $leftCell, string $rightCell)
{
$this->workbookManager->getCurrentWorksheet()->unMergeCells($leftCell,$rightCell);
}
}