Merge pull request #2 from Rdtynby/set_the_first_column_explicitly

Set the first column explicitly.
This commit is contained in:
Rdtynby 2017-09-15 12:11:07 +03:00 committed by GitHub
commit f4b741d2c4

View File

@ -85,18 +85,17 @@ class Writer extends AbstractMultiSheetsWriter
/** /**
* Add a width definition for the next sheet that will be generated * Add a width definition for the next sheet that will be generated
* @param number $width column width * @param number $width column width
* @param int $start 1-based number of the first column where this width should take effect
* @param int $count column range size where this width should take effect (default 1) * @param int $count column range size where this width should take effect (default 1)
* @return Writer * @return Writer
*/ */
public function setColumnWidth($width, $count = 1) public function setColumnWidth($width, $start, $count = 1)
{ {
$countExisted = count($this->columnWidths); $max = $start + $count - 1;
$min = $countExisted ? $this->columnWidths[$countExisted - 1]['max'] + 1 : 1;
$max = $min + $count - 1;
$this->columnWidths[] = [ $this->columnWidths[] = [
'width' => $width, 'width' => $width,
'min' => $min, 'min' => $start,
'max' => $max 'max' => $max
]; ];