1 | <?php |
||
15 | class Writer extends AbstractMultiSheetsWriter |
||
16 | { |
||
17 | /** @var string Content-Type value for the header */ |
||
18 | protected static $headerContentType = 'application/vnd.oasis.opendocument.spreadsheet'; |
||
19 | |||
20 | /** @var string Temporary folder where the files to create the ODS will be stored */ |
||
21 | protected $tempFolder; |
||
22 | |||
23 | /** @var Internal\Workbook The workbook for the XLSX file */ |
||
24 | protected $book; |
||
25 | |||
26 | /** |
||
27 | * Sets a custom temporary folder for creating intermediate files/folders. |
||
28 | * This must be set before opening the writer. |
||
29 | * |
||
30 | * @api |
||
31 | * @param string $tempFolder Temporary folder where the files to create the ODS will be stored |
||
32 | * @return Writer |
||
33 | * @throws \Box\Spout\Writer\Exception\WriterAlreadyOpenedException If the writer was already opened |
||
34 | */ |
||
35 | 6 | public function setTempFolder($tempFolder) |
|
36 | { |
||
37 | 6 | $this->throwIfWriterAlreadyOpened('Writer must be configured before opening it.'); |
|
38 | |||
39 | 3 | $this->tempFolder = $tempFolder; |
|
40 | 3 | return $this; |
|
41 | 3 | } |
|
42 | |||
43 | /** |
||
44 | * Configures the write and sets the current sheet pointer to a new sheet. |
||
45 | * |
||
46 | * @return void |
||
47 | * @throws \Box\Spout\Common\Exception\IOException If unable to open the file for writing |
||
48 | */ |
||
49 | 117 | protected function openWriter() |
|
55 | |||
56 | /** |
||
57 | * @return Internal\Workbook The workbook representing the file to be written |
||
58 | */ |
||
59 | 93 | protected function getWorkbook() |
|
63 | |||
64 | /** |
||
65 | * Adds data to the currently opened writer. |
||
66 | * If shouldCreateNewSheetsAutomatically option is set to true, it will handle pagination |
||
67 | * with the creation of new worksheets if one worksheet has reached its maximum capicity. |
||
68 | * |
||
69 | * @param array $dataRow Array containing data to be written. |
||
70 | * Example $dataRow = ['data1', 1234, null, '', 'data5']; |
||
71 | * @param \Box\Spout\Writer\Style\Style $style Style to be applied to the row. |
||
72 | * @return void |
||
73 | * @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If the book is not created yet |
||
74 | * @throws \Box\Spout\Common\Exception\IOException If unable to write data |
||
75 | */ |
||
76 | 84 | protected function addRowToWriter(array $dataRow, $style) |
|
81 | |||
82 | /** |
||
83 | * Closes the writer, preventing any additional writing. |
||
84 | * |
||
85 | * @return void |
||
86 | */ |
||
87 | 90 | protected function closeWriter() |
|
93 | } |
||
94 |