1 | <?php |
||
20 | class WorksheetManager implements WorksheetManagerInterface |
||
21 | { |
||
22 | /** @var \Box\Spout\Common\Helper\Escaper\ODS Strings escaper */ |
||
23 | private $stringsEscaper; |
||
24 | |||
25 | /** @var StringHelper String helper */ |
||
26 | private $stringHelper; |
||
27 | |||
28 | /** @var StyleManager Manages styles */ |
||
29 | private $styleManager; |
||
30 | |||
31 | /** |
||
32 | * WorksheetManager constructor. |
||
33 | * |
||
34 | * @param StyleManager $styleManager |
||
35 | * @param ODSEscaper $stringsEscaper |
||
36 | * @param StringHelper $stringHelper |
||
37 | */ |
||
38 | 35 | public function __construct( |
|
47 | |||
48 | /** |
||
49 | * Prepares the worksheet to accept data |
||
50 | * |
||
51 | * @param Worksheet $worksheet The worksheet to start |
||
52 | * @throws \Box\Spout\Common\Exception\IOException If the sheet data file cannot be opened for writing |
||
53 | * @return void |
||
54 | */ |
||
55 | 35 | public function startSheet(Worksheet $worksheet) |
|
62 | |||
63 | /** |
||
64 | * Checks if the sheet has been sucessfully created. Throws an exception if not. |
||
65 | * |
||
66 | * @param bool|resource $sheetFilePointer Pointer to the sheet data file or FALSE if unable to open the file |
||
67 | * @throws IOException If the sheet data file cannot be opened for writing |
||
68 | * @return void |
||
69 | */ |
||
70 | 35 | private function throwIfSheetFilePointerIsNotAvailable($sheetFilePointer) |
|
76 | |||
77 | /** |
||
78 | * Returns the table XML root node as string. |
||
79 | * |
||
80 | * @param Worksheet $worksheet |
||
81 | * @return string <table> node as string |
||
82 | */ |
||
83 | 32 | public function getTableElementStartAsString(Worksheet $worksheet) |
|
94 | |||
95 | /** |
||
96 | * Adds a row to the given worksheet. |
||
97 | * |
||
98 | * @param Worksheet $worksheet The worksheet to add the row to |
||
99 | * @param Row $row The row to be added |
||
100 | * @throws IOException If the data cannot be written |
||
101 | * @throws InvalidArgumentException If a cell value's type is not supported |
||
102 | * @return void |
||
103 | */ |
||
104 | 29 | public function addRow(Worksheet $worksheet, Row $row) |
|
140 | |||
141 | /** |
||
142 | * Applies styles to the given style, merging the cell's style with its row's style |
||
143 | * Then builds and returns xml for the cell. |
||
144 | * |
||
145 | * @param Cell $cell |
||
146 | * @param Style $rowStyle |
||
147 | * @param int $currentCellIndex |
||
148 | * @param int $nextCellIndex |
||
149 | * @throws InvalidArgumentException If a cell value's type is not supported |
||
150 | * @return string |
||
151 | */ |
||
152 | 29 | private function applyStyleAndGetCellXML(Cell $cell, Style $rowStyle, $currentCellIndex, $nextCellIndex) |
|
164 | |||
165 | /** |
||
166 | * Returns the cell XML content, given its value. |
||
167 | * |
||
168 | * @param Cell $cell The cell to be written |
||
169 | * @param int $styleIndex Index of the used style |
||
170 | * @param int $numTimesValueRepeated Number of times the value is consecutively repeated |
||
171 | * @throws InvalidArgumentException If a cell value's type is not supported |
||
172 | * @return string The cell XML content |
||
173 | */ |
||
174 | 29 | private function getCellXML(Cell $cell, $styleIndex, $numTimesValueRepeated) |
|
207 | |||
208 | /** |
||
209 | * Closes the worksheet |
||
210 | * |
||
211 | * @param Worksheet $worksheet |
||
212 | * @return void |
||
213 | */ |
||
214 | 32 | public function close(Worksheet $worksheet) |
|
224 | } |
||
225 |