This repository has been archived by the owner on May 26, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 637
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for default cell sizes for ODS files
- Loading branch information
1 parent
6db9871
commit 26ad590
Showing
3 changed files
with
104 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
use Box\Spout\Common\Exception\IOException; | ||
use Box\Spout\Common\Helper\Escaper\ODS as ODSEscaper; | ||
use Box\Spout\Common\Helper\StringHelper; | ||
use Box\Spout\Writer\Common\Entity\Options; | ||
use Box\Spout\Writer\Common\Entity\Worksheet; | ||
use Box\Spout\Writer\Common\Manager\Style\StyleMerger; | ||
use Box\Spout\Writer\Common\Manager\WorksheetManagerInterface; | ||
|
@@ -39,17 +40,25 @@ class WorksheetManager implements WorksheetManagerInterface | |
* @param StyleMerger $styleMerger | ||
* @param ODSEscaper $stringsEscaper | ||
* @param StringHelper $stringHelper | ||
* @param OptionsManager|null $optionsManager | ||
*/ | ||
public function __construct( | ||
StyleManager $styleManager, | ||
StyleMerger $styleMerger, | ||
ODSEscaper $stringsEscaper, | ||
StringHelper $stringHelper | ||
StringHelper $stringHelper, | ||
$optionsManager = null | ||
) { | ||
$this->styleManager = $styleManager; | ||
$this->styleMerger = $styleMerger; | ||
$this->stringsEscaper = $stringsEscaper; | ||
$this->stringHelper = $stringHelper; | ||
|
||
if ($optionsManager) { | ||
$this->setDefaultColumnWidth($optionsManager->getOption(Options::DEFAULT_COLUMN_WIDTH)); | ||
$this->setDefaultRowHeight($optionsManager->getOption(Options::DEFAULT_ROW_HEIGHT)); | ||
$this->columnWidths = $optionsManager->getOption(Options::COLUMN_WIDTHS) ?? []; | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -229,4 +238,39 @@ public function close(Worksheet $worksheet) | |
|
||
fclose($worksheetFilePointer); | ||
} | ||
|
||
/** | ||
* @param float|null $width | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
aphofstede
Author
|
||
*/ | ||
public function setDefaultColumnWidth($width) | ||
{ | ||
$this->styleManager->setDefaultColumnWidth($width); | ||
} | ||
|
||
/** | ||
* @param float|null $height | ||
*/ | ||
public function setDefaultRowHeight($height) | ||
{ | ||
$this->styleManager->setDefaultRowHeight($height); | ||
} | ||
|
||
/** | ||
* @param float $width | ||
* @param array $columns One or more columns with this width | ||
*/ | ||
public function setColumnWidth(float $width, ...$columns) | ||
{ | ||
$this->styleManager->setColumnWidth($width, ...$columns); | ||
} | ||
|
||
/** | ||
* @param float $width The width to set | ||
* @param int $start First column index of the range | ||
* @param int $end Last column index of the range | ||
*/ | ||
public function setColumnWidthForRange(float $width, int $start, int $end) | ||
{ | ||
$this->styleManager->setColumnWidthForRange($width, $start, $end); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You have some
@params
like thisfloat|null $width
here widthpublic function setDefaultColumnWidth(float $width)
: https://github.com/box/spout/compare/master...aphofstede:custom-column-widths?expand=1#diff-3ebea09d8780d7e83288263911c1e386R294 I guess the PHPSTORM added thenull