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);
|
$worksheetFilePath = $this->getWorksheetFilePath($sheet);
|
||||||
$worksheet = $this->entityFactory->createWorksheet($worksheetFilePath, $sheet);
|
$worksheet = $this->entityFactory->createWorksheet($worksheetFilePath, $sheet);
|
||||||
|
|
||||||
$this->worksheetManager->startSheet($worksheet);
|
|
||||||
|
|
||||||
$worksheets[] = $worksheet;
|
$worksheets[] = $worksheet;
|
||||||
$this->workbook->setWorksheets($worksheets);
|
$this->workbook->setWorksheets($worksheets);
|
||||||
|
|
||||||
@ -157,6 +155,16 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
|||||||
return $this->currentWorksheet;
|
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.
|
* 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).
|
* The writing will resume where it stopped (i.e. data won't be truncated).
|
||||||
|
@ -30,6 +30,11 @@ interface WorkbookManagerInterface
|
|||||||
*/
|
*/
|
||||||
public function addNewSheetAndMakeItCurrent();
|
public function addNewSheetAndMakeItCurrent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void starts the current sheet and opens its file pointer
|
||||||
|
*/
|
||||||
|
public function startCurrentSheet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Worksheet[] All the workbook's sheets
|
* @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\Creator\HelperFactory;
|
||||||
use Box\Spout\Common\Entity\Row;
|
use Box\Spout\Common\Entity\Row;
|
||||||
|
use Box\Spout\Common\Exception\SpoutException;
|
||||||
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
||||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||||
use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface;
|
use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface;
|
||||||
@ -107,6 +108,24 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
|
|||||||
return $worksheet->getExternalSheet();
|
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
|
* Returns the current sheet
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user