PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.5
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.5
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Services / Spout / Writer / ODS / Writer.php

Writer.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.5, at app/Services/Spout/Writer/ODS/Writer.php

94 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Box\Spout\Writer\ODS;
4
5 use Box\Spout\Writer\AbstractMultiSheetsWriter;
6 use Box\Spout\Writer\Common;
7 use Box\Spout\Writer\ODS\Internal\Workbook;
8
9 /**
10 * Class Writer
11 * This class provides base support to write data to ODS files
12 *
13 * @package Box\Spout\Writer\ODS
14 */
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 ODS 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 public function setTempFolder($tempFolder)
36 {
37 $this->throwIfWriterAlreadyOpened('Writer must be configured before opening it.');
38
39 $this->tempFolder = $tempFolder;
40 return $this;
41 }
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 protected function openWriter()
50 {
51 $tempFolder = ($this->tempFolder) ? : sys_get_temp_dir();
52 $this->book = new Workbook($tempFolder, $this->shouldCreateNewSheetsAutomatically, $this->defaultRowStyle);
53 $this->book->addNewSheetAndMakeItCurrent();
54 }
55
56 /**
57 * @return Internal\Workbook The workbook representing the file to be written
58 */
59 protected function getWorkbook()
60 {
61 return $this->book;
62 }
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 protected function addRowToWriter(array $dataRow, $style)
77 {
78 $this->throwIfBookIsNotAvailable();
79 $this->book->addRowToCurrentWorksheet($dataRow, $style);
80 }
81
82 /**
83 * Closes the writer, preventing any additional writing.
84 *
85 * @return void
86 */
87 protected function closeWriter()
88 {
89 if ($this->book) {
90 $this->book->close($this->filePointer);
91 }
92 }
93 }
94