| 1 |
<?php |
| 2 |
|
| 3 |
namespace OpenSpout\Writer; |
| 4 |
|
| 5 |
use OpenSpout\Common\Entity\Row; |
| 6 |
use OpenSpout\Common\Entity\Style\Style; |
| 7 |
|
| 8 |
/** |
| 9 |
* Interface WriterInterface. |
| 10 |
*/ |
| 11 |
interface WriterInterface |
| 12 |
{ |
| 13 |
/** |
| 14 |
* Initializes the writer and opens it to accept data. |
| 15 |
* By using this method, the data will be written to a file. |
| 16 |
* |
| 17 |
* @param string $outputFilePath Path of the output file that will contain the data |
| 18 |
* |
| 19 |
* @throws \OpenSpout\Common\Exception\IOException If the writer cannot be opened or if the given path is not writable |
| 20 |
* |
| 21 |
* @return WriterInterface |
| 22 |
*/ |
| 23 |
public function openToFile($outputFilePath); |
| 24 |
|
| 25 |
/** |
| 26 |
* Initializes the writer and opens it to accept data. |
| 27 |
* By using this method, the data will be outputted directly to the browser. |
| 28 |
* |
| 29 |
* @param string $outputFileName Name of the output file that will contain the data. If a path is passed in, only the file name will be kept |
| 30 |
* |
| 31 |
* @throws \OpenSpout\Common\Exception\IOException If the writer cannot be opened |
| 32 |
* |
| 33 |
* @return WriterInterface |
| 34 |
*/ |
| 35 |
public function openToBrowser($outputFileName); |
| 36 |
|
| 37 |
/** |
| 38 |
* Sets the default styles for all rows added with "addRow". |
| 39 |
* Overriding the default style instead of using "addRowWithStyle" improves performance by 20%. |
| 40 |
* |
| 41 |
* @see https://github.com/box/spout/issues/272 |
| 42 |
* |
| 43 |
* @return WriterInterface |
| 44 |
*/ |
| 45 |
public function setDefaultRowStyle(Style $defaultStyle); |
| 46 |
|
| 47 |
/** |
| 48 |
* Appends a row to the end of the stream. |
| 49 |
* |
| 50 |
* @param Row $row The row to be appended to the stream |
| 51 |
* |
| 52 |
* @throws \OpenSpout\Writer\Exception\WriterNotOpenedException If the writer has not been opened yet |
| 53 |
* @throws \OpenSpout\Common\Exception\IOException If unable to write data |
| 54 |
* |
| 55 |
* @return WriterInterface |
| 56 |
*/ |
| 57 |
public function addRow(Row $row); |
| 58 |
|
| 59 |
/** |
| 60 |
* Appends the rows to the end of the stream. |
| 61 |
* |
| 62 |
* @param Row[] $rows The rows to be appended to the stream |
| 63 |
* |
| 64 |
* @throws \OpenSpout\Common\Exception\InvalidArgumentException If the input param is not valid |
| 65 |
* @throws \OpenSpout\Writer\Exception\WriterNotOpenedException If the writer has not been opened yet |
| 66 |
* @throws \OpenSpout\Common\Exception\IOException If unable to write data |
| 67 |
* |
| 68 |
* @return WriterInterface |
| 69 |
*/ |
| 70 |
public function addRows(array $rows); |
| 71 |
|
| 72 |
/** |
| 73 |
* Closes the writer. This will close the streamer as well, preventing new data |
| 74 |
* to be written to the file. |
| 75 |
*/ |
| 76 |
public function close(); |
| 77 |
} |
| 78 |
|