1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace OpenSpout\Writer\Common\Manager;
|
|
|
6 |
|
|
|
7 |
use OpenSpout\Common\Entity\Row;
|
|
|
8 |
use OpenSpout\Common\Exception\IOException;
|
|
|
9 |
use OpenSpout\Writer\Common\Entity\Sheet;
|
|
|
10 |
use OpenSpout\Writer\Common\Entity\Worksheet;
|
|
|
11 |
use OpenSpout\Writer\Exception\SheetNotFoundException;
|
|
|
12 |
use OpenSpout\Writer\Exception\WriterException;
|
|
|
13 |
|
|
|
14 |
/**
|
|
|
15 |
* @internal
|
|
|
16 |
*/
|
|
|
17 |
interface WorkbookManagerInterface
|
|
|
18 |
{
|
|
|
19 |
/**
|
|
|
20 |
* Creates a new sheet in the workbook and make it the current sheet.
|
|
|
21 |
* The writing will resume where it stopped (i.e. data won't be truncated).
|
|
|
22 |
*
|
|
|
23 |
* @return Worksheet The created sheet
|
|
|
24 |
*
|
|
|
25 |
* @throws IOException If unable to open the sheet for writing
|
|
|
26 |
*/
|
|
|
27 |
public function addNewSheetAndMakeItCurrent(): Worksheet;
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* @return Worksheet[] All the workbook's sheets
|
|
|
31 |
*/
|
|
|
32 |
public function getWorksheets(): array;
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* Returns the current sheet.
|
|
|
36 |
*
|
|
|
37 |
* @return Worksheet The current sheet
|
|
|
38 |
*/
|
|
|
39 |
public function getCurrentWorksheet(): Worksheet;
|
|
|
40 |
|
|
|
41 |
/**
|
|
|
42 |
* Sets the given sheet as the current one. New data will be written to this sheet.
|
|
|
43 |
* The writing will resume where it stopped (i.e. data won't be truncated).
|
|
|
44 |
*
|
|
|
45 |
* @param Sheet $sheet The "external" sheet to set as current
|
|
|
46 |
*
|
|
|
47 |
* @throws SheetNotFoundException If the given sheet does not exist in the workbook
|
|
|
48 |
*/
|
|
|
49 |
public function setCurrentSheet(Sheet $sheet): void;
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Adds a row to the current sheet.
|
|
|
53 |
* If shouldCreateNewSheetsAutomatically option is set to true, it will handle pagination
|
|
|
54 |
* with the creation of new worksheets if one worksheet has reached its maximum capicity.
|
|
|
55 |
*
|
|
|
56 |
* @param Row $row The row to be added
|
|
|
57 |
*
|
|
|
58 |
* @throws IOException If trying to create a new sheet and unable to open the sheet for writing
|
|
|
59 |
* @throws WriterException If unable to write data
|
|
|
60 |
*/
|
|
|
61 |
public function addRowToCurrentWorksheet(Row $row): void;
|
|
|
62 |
|
|
|
63 |
/**
|
|
|
64 |
* Closes the workbook and all its associated sheets.
|
|
|
65 |
* All the necessary files are written to disk and zipped together to create the final file.
|
|
|
66 |
* All the temporary files are then deleted.
|
|
|
67 |
*
|
|
|
68 |
* @param resource $finalFilePointer Pointer to the spreadsheet that will be created
|
|
|
69 |
*/
|
|
|
70 |
public function close($finalFilePointer): void;
|
|
|
71 |
}
|