fix to not start fwrites on sheet when it is initially created
This commit is contained in:
parent
85063fc4d2
commit
c3d3c5ffbf
@ -131,8 +131,6 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
$worksheetFilePath = $this->getWorksheetFilePath($sheet);
|
||||
$worksheet = $this->entityFactory->createWorksheet($worksheetFilePath, $sheet);
|
||||
|
||||
$this->worksheetManager->startSheet($worksheet);
|
||||
|
||||
$worksheets[] = $worksheet;
|
||||
$this->workbook->setWorksheets($worksheets);
|
||||
|
||||
@ -157,6 +155,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).
|
||||
|
@ -30,6 +30,11 @@ interface WorkbookManagerInterface
|
||||
*/
|
||||
public function addNewSheetAndMakeItCurrent();
|
||||
|
||||
/**
|
||||
* @return void starts the current sheet and opens its file pointer
|
||||
*/
|
||||
public function startCurrentSheet();
|
||||
|
||||
/**
|
||||
* @return Worksheet[] All the workbook's sheets
|
||||
*/
|
||||
|
@ -4,6 +4,7 @@ namespace Box\Spout\Writer;
|
||||
|
||||
use Box\Spout\Common\Creator\HelperFactory;
|
||||
use Box\Spout\Common\Entity\Row;
|
||||
use Box\Spout\Common\Exception\SpoutException;
|
||||
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface;
|
||||
@ -107,6 +108,24 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
|
||||
return $worksheet->getExternalSheet();
|
||||
}
|
||||
|
||||
public function startCurrentSheet()
|
||||
{
|
||||
$this->workbookManager->startCurrentSheet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Row $row
|
||||
* @throws WriterNotOpenedException|SpoutException
|
||||
* @return WriterAbstract
|
||||
*/
|
||||
public function addRow(Row $row)
|
||||
{
|
||||
if (!$this->workbookManager->getCurrentWorksheet()->getFilePointer()){
|
||||
$this->startCurrentSheet();
|
||||
}
|
||||
return parent::addRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current sheet
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user