Add XLSX support for default column width/row height as well as custom column widths through writer or OptionsManager (and test for it)

This commit is contained in:
Alexander Hofstede committed 2019-12-13 00:12:09 +01:00
1 parent 2d297e954b
commit 82170a058b
7 files changed
+311 -10

No files matched your search

@@ -103,7 +103,6 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* Creates a new sheet in the workbook and make it the current sheet.
* The writing will resume where it stopped (i.e. data won't be truncated).
*
* @throws IOException If unable to open the sheet for writing
* @return Worksheet The created sheet
*/
public function addNewSheetAndMakeItCurrent()
@@ -117,8 +116,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
/**
* Creates a new sheet in the workbook. The current sheet remains unchanged.
*
* @throws \Box\Spout\Common\Exception\IOException If unable to open the sheet for writing
* @return Worksheet The created sheet
* @throws IOException
*/
private function addNewSheet()
{
@@ -157,6 +156,16 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
return $this->currentWorksheet;
}
/**
* Starts the current sheet and opens the file pointer
*
* @throws IOException
*/
public function startCurrentSheet()
{
$this->worksheetManager->startSheet($this->getCurrentWorksheet());
}
/**
* Sets the given sheet as the current one. New data will be written to this sheet.
* The writing will resume where it stopped (i.e. data won't be truncated).
@@ -210,9 +219,10 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* with the creation of new worksheets if one worksheet has reached its maximum capicity.
*
* @param Row $row The row to be added
* @throws IOException If trying to create a new sheet and unable to open the sheet for writing
* @throws WriterException If unable to write data
*
* @return void
* @throws IOException If trying to create a new sheet and unable to open the sheet for writing
* @throws \Box\Spout\Common\Exception\InvalidArgumentException
*/
public function addRowToCurrentWorksheet(Row $row)
{
@@ -249,8 +259,10 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
*
* @param Worksheet $worksheet Worksheet to write the row to
* @param Row $row The row to be added
* @throws WriterException If unable to write data
*
* @return void
* @throws IOException
* @throws \Box\Spout\Common\Exception\InvalidArgumentException
*/
private function addRowToWorksheet(Worksheet $worksheet, Row $row)
{
@@ -276,6 +288,28 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
}
}
/**
* @param float|null $width
*/
public function setDefaultColumnWidth(float $width) {
$this->worksheetManager->setDefaultColumnWidth($width);
}
/**
* @param float|null $height
*/
public function setDefaultRowHeight(float $height) {
$this->worksheetManager->setDefaultRowHeight($height);
}
/**
* @param float|null $width
* @param array $columns One or more columns with this width
*/
public function setColumnWidth($width, ...$columns) {
$this->worksheetManager->setColumnWidth($width, ...$columns);
}
/**
* Closes the workbook and all its associated sheets.
* All the necessary files are written to disk and zipped together to create the final file.