1 | <?php |
||
17 | class Worksheet implements WorksheetInterface |
||
18 | { |
||
19 | const SHEET_XML_FILE_HEADER = <<<EOD |
||
20 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
||
21 | <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> |
||
22 | EOD; |
||
23 | |||
24 | /** @var \Box\Spout\Writer\Common\Sheet The "external" sheet */ |
||
25 | protected $externalSheet; |
||
26 | |||
27 | /** @var string Path to the XML file that will contain the sheet data */ |
||
28 | protected $worksheetFilePath; |
||
29 | |||
30 | /** @var \Box\Spout\Writer\XLSX\Helper\SharedStringsHelper Helper to write shared strings */ |
||
31 | protected $sharedStringsHelper; |
||
32 | |||
33 | /** @var bool Whether inline or shared strings should be used */ |
||
34 | protected $shouldUseInlineStrings; |
||
35 | |||
36 | /** @var \Box\Spout\Common\Escaper\XLSX Strings escaper */ |
||
37 | protected $stringsEscaper; |
||
38 | |||
39 | /** @var Resource Pointer to the sheet data file (e.g. xl/worksheets/sheet1.xml) */ |
||
40 | protected $sheetFilePointer; |
||
41 | |||
42 | /** @var int Index of the last written row */ |
||
43 | protected $lastWrittenRowIndex = 0; |
||
44 | |||
45 | /** |
||
46 | * @param \Box\Spout\Writer\Common\Sheet $externalSheet The associated "external" sheet |
||
47 | * @param string $worksheetFilesFolder Temporary folder where the files to create the XLSX will be stored |
||
48 | * @param \Box\Spout\Writer\XLSX\Helper\SharedStringsHelper $sharedStringsHelper Helper for shared strings |
||
49 | * @param bool $shouldUseInlineStrings Whether inline or shared strings should be used |
||
50 | * @throws \Box\Spout\Common\Exception\IOException If the sheet data file cannot be opened for writing |
||
51 | */ |
||
52 | public function __construct($externalSheet, $worksheetFilesFolder, $sharedStringsHelper, $shouldUseInlineStrings) |
||
64 | |||
65 | /** |
||
66 | * Prepares the worksheet to accept data |
||
67 | * |
||
68 | * @return void |
||
69 | * @throws \Box\Spout\Common\Exception\IOException If the sheet data file cannot be opened for writing |
||
70 | */ |
||
71 | protected function startSheet() |
||
79 | |||
80 | /** |
||
81 | * Checks if the book has been created. Throws an exception if not created yet. |
||
82 | * |
||
83 | * @return void |
||
84 | * @throws \Box\Spout\Common\Exception\IOException If the sheet data file cannot be opened for writing |
||
85 | */ |
||
86 | protected function throwIfSheetFilePointerIsNotAvailable() |
||
92 | |||
93 | /** |
||
94 | * @return \Box\Spout\Writer\Common\Sheet The "external" sheet |
||
95 | */ |
||
96 | public function getExternalSheet() |
||
100 | |||
101 | /** |
||
102 | * @return int The index of the last written row |
||
103 | */ |
||
104 | public function getLastWrittenRowIndex() |
||
108 | |||
109 | /** |
||
110 | * @return int The ID of the worksheet |
||
111 | */ |
||
112 | public function getId() |
||
117 | |||
118 | /** |
||
119 | * Adds data to the worksheet. |
||
120 | * |
||
121 | * @param array $dataRow Array containing data to be written. Cannot be empty. |
||
122 | * Example $dataRow = ['data1', 1234, null, '', 'data5']; |
||
123 | * @param \Box\Spout\Writer\Style\Style $style Style to be applied to the row. NULL means use default style. |
||
124 | * @return void |
||
125 | * @throws \Box\Spout\Common\Exception\IOException If the data cannot be written |
||
126 | * @throws \Box\Spout\Common\Exception\InvalidArgumentException If a cell value's type is not supported |
||
127 | */ |
||
128 | public function addRow($dataRow, $style) |
||
173 | |||
174 | /** |
||
175 | * Closes the worksheet |
||
176 | * |
||
177 | * @return void |
||
178 | */ |
||
179 | public function close() |
||
189 | } |
||
190 |