1 | <?php |
||
18 | abstract class WriterMultiSheetsAbstract extends WriterAbstract |
||
19 | { |
||
20 | |||
21 | /** @var InternalFactoryInterface */ |
||
22 | private $internalFactory; |
||
23 | |||
24 | /** @var WorkbookManagerInterface */ |
||
25 | private $workbookManager; |
||
26 | |||
27 | /** |
||
28 | * @param OptionsManagerInterface $optionsManager |
||
29 | * @param InternalFactoryInterface $internalFactory |
||
30 | */ |
||
31 | 99 | public function __construct(OptionsManagerInterface $optionsManager, InternalFactoryInterface $internalFactory) |
|
36 | |||
37 | /** |
||
38 | * Sets whether new sheets should be automatically created when the max rows limit per sheet is reached. |
||
39 | * This must be set before opening the writer. |
||
40 | * |
||
41 | * @api |
||
42 | * @param bool $shouldCreateNewSheetsAutomatically Whether new sheets should be automatically created when the max rows limit per sheet is reached |
||
43 | * @return WriterMultiSheetsAbstract |
||
44 | * @throws \Box\Spout\Writer\Exception\WriterAlreadyOpenedException If the writer was already opened |
||
45 | */ |
||
46 | 35 | public function setShouldCreateNewSheetsAutomatically($shouldCreateNewSheetsAutomatically) |
|
53 | |||
54 | /** |
||
55 | * Configures the write and sets the current sheet pointer to a new sheet. |
||
56 | * |
||
57 | * @return void |
||
58 | * @throws \Box\Spout\Common\Exception\IOException If unable to open the file for writing |
||
59 | */ |
||
60 | 89 | protected function openWriter() |
|
67 | |||
68 | /** |
||
69 | * Returns all the workbook's sheets |
||
70 | * |
||
71 | * @api |
||
72 | * @return Common\Sheet[] All the workbook's sheets |
||
73 | * @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If the writer has not been opened yet |
||
74 | */ |
||
75 | 14 | public function getSheets() |
|
89 | |||
90 | /** |
||
91 | * Creates a new sheet and make it the current sheet. The data will now be written to this sheet. |
||
92 | * |
||
93 | * @api |
||
94 | * @return Common\Sheet The created sheet |
||
95 | * @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If the writer has not been opened yet |
||
96 | */ |
||
97 | 15 | public function addNewSheetAndMakeItCurrent() |
|
104 | |||
105 | /** |
||
106 | * Returns the current sheet |
||
107 | * |
||
108 | * @api |
||
109 | * @return Common\Sheet The current sheet |
||
110 | * @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If the writer has not been opened yet |
||
111 | */ |
||
112 | 8 | public function getCurrentSheet() |
|
117 | |||
118 | /** |
||
119 | * Sets the given sheet as the current one. New data will be written to this sheet. |
||
120 | * The writing will resume where it stopped (i.e. data won't be truncated). |
||
121 | * |
||
122 | * @api |
||
123 | * @param Common\Sheet $sheet The sheet to set as current |
||
124 | * @return void |
||
125 | * @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If the writer has not been opened yet |
||
126 | * @throws \Box\Spout\Writer\Exception\SheetNotFoundException If the given sheet does not exist in the workbook |
||
127 | */ |
||
128 | 4 | public function setCurrentSheet($sheet) |
|
133 | |||
134 | /** |
||
135 | * Checks if the workbook has been created. Throws an exception if not created yet. |
||
136 | * |
||
137 | * @return void |
||
138 | * @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If the workbook is not created yet |
||
139 | */ |
||
140 | 70 | protected function throwIfWorkbookIsNotAvailable() |
|
146 | |||
147 | /** |
||
148 | * Adds data to the currently opened writer. |
||
149 | * If shouldCreateNewSheetsAutomatically option is set to true, it will handle pagination |
||
150 | * with the creation of new worksheets if one worksheet has reached its maximum capicity. |
||
151 | * |
||
152 | * @param array $dataRow Array containing data to be written. |
||
153 | * Example $dataRow = ['data1', 1234, null, '', 'data5']; |
||
154 | * @param \Box\Spout\Writer\Style\Style $style Style to be applied to the row. |
||
155 | * @return void |
||
156 | * @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If the book is not created yet |
||
157 | * @throws \Box\Spout\Common\Exception\IOException If unable to write data |
||
158 | */ |
||
159 | 64 | protected function addRowToWriter(array $dataRow, $style) |
|
164 | |||
165 | /** |
||
166 | * Closes the writer, preventing any additional writing. |
||
167 | * |
||
168 | * @return void |
||
169 | */ |
||
170 | 70 | protected function closeWriter() |
|
176 | } |
||
177 | |||
178 |