1 | <?php |
||
15 | class Writer extends AbstractMultiSheetsWriter |
||
16 | { |
||
17 | /** Default style font values */ |
||
18 | const DEFAULT_FONT_SIZE = 12; |
||
19 | const DEFAULT_FONT_NAME = 'Calibri'; |
||
20 | |||
21 | /** @var string Content-Type value for the header */ |
||
22 | protected static $headerContentType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; |
||
23 | |||
24 | /** @var string Temporary folder where the files to create the XLSX will be stored */ |
||
25 | protected $tempFolder; |
||
26 | |||
27 | /** @var bool Whether inline or shared strings should be used - inline string is more memory efficient */ |
||
28 | protected $shouldUseInlineStrings = true; |
||
29 | |||
30 | /** @var bool Determine whether cell widths should be calculated */ |
||
31 | protected $shouldUseCellAutosizing = false; |
||
32 | |||
33 | /** @var Internal\Workbook The workbook for the XLSX file */ |
||
34 | protected $book; |
||
35 | |||
36 | /** |
||
37 | * Sets a custom temporary folder for creating intermediate files/folders. |
||
38 | * This must be set before opening the writer. |
||
39 | * |
||
40 | * @api |
||
41 | * @param string $tempFolder Temporary folder where the files to create the XLSX will be stored |
||
42 | * @return Writer |
||
43 | * @throws \Box\Spout\Writer\Exception\WriterAlreadyOpenedException If the writer was already opened |
||
44 | */ |
||
45 | 6 | public function setTempFolder($tempFolder) |
|
52 | |||
53 | /** |
||
54 | * Use inline string to be more memory efficient. If set to false, it will use shared strings. |
||
55 | * This must be set before opening the writer. |
||
56 | * |
||
57 | * @api |
||
58 | * @param bool $shouldUseInlineStrings Whether inline or shared strings should be used |
||
59 | * @return Writer |
||
60 | * @throws \Box\Spout\Writer\Exception\WriterAlreadyOpenedException If the writer was already opened |
||
61 | */ |
||
62 | 84 | public function setShouldUseInlineStrings($shouldUseInlineStrings) |
|
69 | |||
70 | /** |
||
71 | * Enable or disable automated calculation of cell sizes to fit the contents of a cell value. |
||
72 | * |
||
73 | * @api |
||
74 | * @param bool $shouldUseCellAutosizing |
||
75 | * @return Writer |
||
76 | * @throws \Box\Spout\Writer\Exception\WriterAlreadyOpenedException If the writer was already opened |
||
77 | */ |
||
78 | 3 | public function setShouldUseCellAutosizing($shouldUseCellAutosizing) |
|
85 | |||
86 | /** |
||
87 | * Configures the write and sets the current sheet pointer to a new sheet. |
||
88 | * |
||
89 | * @return void |
||
90 | * @throws \Box\Spout\Common\Exception\IOException If unable to open the file for writing |
||
91 | */ |
||
92 | 132 | protected function openWriter() |
|
106 | |||
107 | /** |
||
108 | * @return Internal\Workbook The workbook representing the file to be written |
||
109 | */ |
||
110 | 102 | protected function getWorkbook() |
|
114 | |||
115 | /** |
||
116 | * Adds data to the currently opened writer. |
||
117 | * If shouldCreateNewSheetsAutomatically option is set to true, it will handle pagination |
||
118 | * with the creation of new worksheets if one worksheet has reached its maximum capicity. |
||
119 | * |
||
120 | * @param array $dataRow Array containing data to be written. |
||
121 | * Example $dataRow = ['data1', 1234, null, '', 'data5']; |
||
122 | * @param \Box\Spout\Writer\Style\Style $style Style to be applied to the row. |
||
123 | * @return void |
||
124 | * @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If the book is not created yet |
||
125 | * @throws \Box\Spout\Common\Exception\IOException If unable to write data |
||
126 | * @throws \Box\Spout\Writer\Exception\WriterException |
||
127 | */ |
||
128 | 93 | protected function addRowToWriter(array $dataRow, $style) |
|
133 | |||
134 | /** |
||
135 | * Returns the default style to be applied to rows. |
||
136 | * |
||
137 | * @return \Box\Spout\Writer\Style\Style |
||
138 | */ |
||
139 | 147 | protected function getDefaultRowStyle() |
|
146 | |||
147 | /** |
||
148 | * Closes the writer, preventing any additional writing. |
||
149 | * @return void |
||
150 | * @throws \Box\Spout\Common\Exception\IOException |
||
151 | */ |
||
152 | 99 | protected function closeWriter() |
|
158 | } |
||
159 |