Use options manager for default row height and column width
This commit is contained in:
parent
36573eaa8a
commit
26e5f966fb
@ -142,22 +142,28 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param float $width
|
* @param float $width
|
||||||
* @throws WriterNotOpenedException
|
* @throws WriterAlreadyOpenedException
|
||||||
*/
|
*/
|
||||||
public function setDefaultColumnWidth(float $width)
|
public function setDefaultColumnWidth(float $width)
|
||||||
{
|
{
|
||||||
$this->throwIfWorkbookIsNotAvailable();
|
$this->throwIfWriterAlreadyOpened('Writer must be configured before opening it.');
|
||||||
$this->workbookManager->setDefaultColumnWidth($width);
|
$this->optionsManager->setOption(
|
||||||
|
Options::DEFAULT_COLUMN_WIDTH,
|
||||||
|
$width
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param float $height
|
* @param float $height
|
||||||
* @throws WriterNotOpenedException
|
* @throws WriterAlreadyOpenedException
|
||||||
*/
|
*/
|
||||||
public function setDefaultRowHeight(float $height)
|
public function setDefaultRowHeight(float $height)
|
||||||
{
|
{
|
||||||
$this->throwIfWorkbookIsNotAvailable();
|
$this->throwIfWriterAlreadyOpened('Writer must be configured before opening it.');
|
||||||
$this->workbookManager->setDefaultRowHeight($height);
|
$this->optionsManager->setOption(
|
||||||
|
Options::DEFAULT_ROW_HEIGHT,
|
||||||
|
$height
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,9 +65,6 @@ EOD;
|
|||||||
/** @var InternalEntityFactory Factory to create entities */
|
/** @var InternalEntityFactory Factory to create entities */
|
||||||
private $entityFactory;
|
private $entityFactory;
|
||||||
|
|
||||||
/** @var bool Whether rows have been written */
|
|
||||||
private $hasWrittenRows = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WorksheetManager constructor.
|
* WorksheetManager constructor.
|
||||||
*
|
*
|
||||||
@ -122,6 +119,9 @@ EOD;
|
|||||||
$worksheet->setFilePointer($sheetFilePointer);
|
$worksheet->setFilePointer($sheetFilePointer);
|
||||||
|
|
||||||
\fwrite($sheetFilePointer, self::SHEET_XML_FILE_HEADER);
|
\fwrite($sheetFilePointer, self::SHEET_XML_FILE_HEADER);
|
||||||
|
\fwrite($sheetFilePointer, $this->getXMLFragmentForDefaultCellSizing());
|
||||||
|
\fwrite($sheetFilePointer, $this->getXMLFragmentForColumnWidths());
|
||||||
|
\fwrite($sheetFilePointer, '<sheetData>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,12 +162,6 @@ EOD;
|
|||||||
private function addNonEmptyRow(Worksheet $worksheet, Row $row)
|
private function addNonEmptyRow(Worksheet $worksheet, Row $row)
|
||||||
{
|
{
|
||||||
$sheetFilePointer = $worksheet->getFilePointer();
|
$sheetFilePointer = $worksheet->getFilePointer();
|
||||||
if (!$this->hasWrittenRows) {
|
|
||||||
fwrite($sheetFilePointer, $this->getXMLFragmentForDefaultCellSizing());
|
|
||||||
fwrite($sheetFilePointer, $this->getXMLFragmentForColumnWidths());
|
|
||||||
fwrite($sheetFilePointer, '<sheetData>');
|
|
||||||
}
|
|
||||||
|
|
||||||
$rowStyle = $row->getStyle();
|
$rowStyle = $row->getStyle();
|
||||||
$rowIndexOneBased = $worksheet->getLastWrittenRowIndex() + 1;
|
$rowIndexOneBased = $worksheet->getLastWrittenRowIndex() + 1;
|
||||||
$numCells = $row->getNumCells();
|
$numCells = $row->getNumCells();
|
||||||
@ -185,7 +179,6 @@ EOD;
|
|||||||
if ($wasWriteSuccessful === false) {
|
if ($wasWriteSuccessful === false) {
|
||||||
throw new IOException("Unable to write data in {$worksheet->getFilePath()}");
|
throw new IOException("Unable to write data in {$worksheet->getFilePath()}");
|
||||||
}
|
}
|
||||||
$this->hasWrittenRows = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -324,9 +317,7 @@ EOD;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->hasWrittenRows) {
|
|
||||||
\fwrite($worksheetFilePointer, '</sheetData>');
|
\fwrite($worksheetFilePointer, '</sheetData>');
|
||||||
}
|
|
||||||
\fwrite($worksheetFilePointer, '</worksheet>');
|
\fwrite($worksheetFilePointer, '</worksheet>');
|
||||||
\fclose($worksheetFilePointer);
|
\fclose($worksheetFilePointer);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user