This commit is contained in:
Lucian Sirbu 2020-07-31 16:06:05 +03:00
parent e290f45880
commit f702127d3a
14 changed files with 26 additions and 19 deletions

View File

@ -22,7 +22,7 @@ class Row
* Row height (default is 15)
* @var string
*/
protected $height = "15";
protected $height = '15';
/**
* Row constructor.
@ -135,18 +135,19 @@ class Row
/**
* Set row height
* @param String $height
* @param string $height
* @return Row
*/
public function setHeight($height)
{
$this->height = $height;
return $this;
}
/**
* Returns row height
* @return String
* @return string
*/
public function getHeight()
{

View File

@ -476,10 +476,11 @@ class Style
{
$this->shrinkToFit = $shrinkToFit;
$this->shouldShrinkToFit = $shrinkToFit;
return $this;
}
/**
/**
* @return bool Whether format should be applied
*/
public function shouldShrinkToFit()

View File

@ -54,6 +54,8 @@ abstract class OptionsManagerAbstract implements OptionsManagerInterface
/**
* Add an option to the internal list of options
* Used only for mergeCells() for now
* @param mixed $optionName
* @param mixed $optionValue
* @return void
*/
public function addOption($optionName, $optionValue)

View File

@ -28,13 +28,13 @@ class SheetIterator implements IteratorInterface
const XML_ATTRIBUTE_TABLE_STYLE_NAME = 'table:style-name';
const XML_ATTRIBUTE_TABLE_DISPLAY = 'table:display';
/** @var string $filePath Path of the file to be read */
/** @var string Path of the file to be read */
protected $filePath;
/** @var \Box\Spout\Common\Manager\OptionsManagerInterface Reader's options manager */
protected $optionsManager;
/** @var InternalEntityFactory $entityFactory Factory to create entities */
/** @var InternalEntityFactory Factory to create entities */
protected $entityFactory;
/** @var XMLReader The XMLReader object that will help read sheet's XML data */

View File

@ -43,7 +43,7 @@ class SharedStringsManager
/** @var InternalEntityFactory Factory to create entities */
protected $entityFactory;
/** @var HelperFactory $helperFactory Factory to create helpers */
/** @var HelperFactory Factory to create helpers */
protected $helperFactory;
/** @var CachingStrategyFactory Factory to create shared strings caching strategies */

View File

@ -35,7 +35,7 @@ class RowIterator implements IteratorInterface
/** @var string Path of the XLSX file being read */
protected $filePath;
/** @var string $sheetDataXMLFilePath Path of the sheet data XML file as in [Content_Types].xml */
/** @var string Path of the sheet data XML file as in [Content_Types].xml */
protected $sheetDataXMLFilePath;
/** @var \Box\Spout\Reader\Wrapper\XMLReader The XMLReader object that will help read sheet's XML data */

View File

@ -185,12 +185,13 @@ class StyleBuilder
/**
* Set should shrink to fit
* @param boolean $shrinkToFit
* @param bool $shrinkToFit
* @return void
*/
public function setShouldShrinkToFit($shrinkToFit = true)
{
$this->style->setShouldShrinkToFit($shrinkToFit);
return $this;
}

View File

@ -44,7 +44,7 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
/** @var InternalEntityFactory Factory to create entities */
protected $entityFactory;
/** @var ManagerFactoryInterface $managerFactory Factory to create managers */
/** @var ManagerFactoryInterface Factory to create managers */
protected $managerFactory;
/** @var Worksheet The worksheet where data will be written to */

View File

@ -22,7 +22,7 @@ class ManagerFactory implements ManagerFactoryInterface
/** @var InternalEntityFactory */
protected $entityFactory;
/** @var HelperFactory $helperFactory */
/** @var HelperFactory */
protected $helperFactory;
/**

View File

@ -33,7 +33,7 @@ abstract class WriterAbstract implements WriterInterface
/** @var GlobalFunctionsHelper Helper to work with global functions */
protected $globalFunctionsHelper;
/** @var HelperFactory $helperFactory */
/** @var HelperFactory */
protected $helperFactory;
/** @var OptionsManagerInterface Writer options manager */

View File

@ -69,6 +69,7 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
public function setColumnWidths(array $columnWidths)
{
$this->optionsManager->setOption(Options::COLUMN_WIDTHS, $columnWidths);
return $this;
}
@ -81,6 +82,7 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
public function mergeCells(array $range1, array $range2)
{
$this->optionsManager->addOption(Options::MERGE_CELLS, [$range1, $range2]);
return $this;
}

View File

@ -24,7 +24,7 @@ class ManagerFactory implements ManagerFactoryInterface
/** @var InternalEntityFactory */
protected $entityFactory;
/** @var HelperFactory $helperFactory */
/** @var HelperFactory */
protected $helperFactory;
/**

View File

@ -161,9 +161,9 @@ EOD;
$colsString = '<cols>';
foreach ($this->optionsManager->getOption(Options::COLUMN_WIDTHS) as $index => $width) {
$index++;
$colsString.= '<col collapsed="false" customWidth="true" hidden="false" outlineLevel="0" style="0" max="'.$index.'" min="'.$index.'" width="'.$width.'"/>';
$colsString.= '<col collapsed="false" customWidth="true" hidden="false" outlineLevel="0" style="0" max="' . $index . '" min="' . $index . '" width="' . $width . '"/>';
}
$colsString.="</cols>";
$colsString.='</cols>';
\fwrite($worksheet->getFilePointer(), $colsString);
}
@ -176,7 +176,7 @@ EOD;
$numCells = $row->getNumCells();
$rowHeight = $row->getHeight();
$rowXML = '<row r="' . $rowIndexOneBased . '" spans="1:' . $numCells . '" customHeight="true"' . ' ht="'. $rowHeight . '">';
$rowXML = '<row r="' . $rowIndexOneBased . '" spans="1:' . $numCells . '" customHeight="true"' . ' ht="' . $rowHeight . '">';
foreach ($row->getCells() as $columnIndexZeroBased => $cell) {
$rowXML .= $this->applyStyleAndGetCellXML($cell, $rowStyle, $rowIndexOneBased, $columnIndexZeroBased);
@ -300,7 +300,7 @@ EOD;
if ($this->optionsManager->getOption(Options::MERGE_CELLS)) {
$mergeCellString = '<mergeCells count="' . \count($this->optionsManager->getOption(Options::MERGE_CELLS)) . '">';
foreach ($this->optionsManager->getOption(Options::MERGE_CELLS) as $values) {
$output = \array_map(function($value){
$output = \array_map(function ($value) {
return CellHelper::getColumnLettersFromColumnIndex($value[0]) . $value[1];
}, $values);
$mergeCellString.= '<mergeCell ref="' . \implode(':', $output) . '"/>';

View File

@ -14,10 +14,10 @@ class SpoutTestStream
const PATH_TO_CSV_RESOURCES = 'tests/resources/csv/';
const CSV_EXTENSION = '.csv';
/** @var int $position */
/** @var int */
private $position;
/** @var resource $fileHandle */
/** @var resource */
private $fileHandle;
/**