| 1 |
<?php |
| 2 |
|
| 3 |
namespace Box\Spout\Writer; |
| 4 |
|
| 5 |
/** |
| 6 |
* Interface WriterInterface |
| 7 |
* |
| 8 |
* @package Box\Spout\Writer |
| 9 |
*/ |
| 10 |
interface WriterInterface |
| 11 |
{ |
| 12 |
/** |
| 13 |
* Inits the writer and opens it to accept data. |
| 14 |
* By using this method, the data will be written to a file. |
| 15 |
* |
| 16 |
* @param string $outputFilePath Path of the output file that will contain the data |
| 17 |
* @return WriterInterface |
| 18 |
* @throws \Box\Spout\Common\Exception\IOException If the writer cannot be opened or if the given path is not writable |
| 19 |
*/ |
| 20 |
public function openToFile($outputFilePath); |
| 21 |
|
| 22 |
/** |
| 23 |
* Inits the writer and opens it to accept data. |
| 24 |
* By using this method, the data will be outputted directly to the browser. |
| 25 |
* |
| 26 |
* @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 |
| 27 |
* @return WriterInterface |
| 28 |
* @throws \Box\Spout\Common\Exception\IOException If the writer cannot be opened |
| 29 |
*/ |
| 30 |
public function openToBrowser($outputFileName); |
| 31 |
|
| 32 |
/** |
| 33 |
* Write given data to the output. New data will be appended to end of stream. |
| 34 |
* |
| 35 |
* @param array $dataRow Array containing data to be streamed. |
| 36 |
* Example $dataRow = ['data1', 1234, null, '', 'data5']; |
| 37 |
* @return WriterInterface |
| 38 |
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If the writer has not been opened yet |
| 39 |
* @throws \Box\Spout\Common\Exception\IOException If unable to write data |
| 40 |
*/ |
| 41 |
public function addRow(array $dataRow); |
| 42 |
|
| 43 |
/** |
| 44 |
* Write given data to the output and apply the given style. |
| 45 |
* @see addRow |
| 46 |
* |
| 47 |
* @param array $dataRow Array of array containing data to be streamed. |
| 48 |
* @param Style\Style $style Style to be applied to the row. |
| 49 |
* @return WriterInterface |
| 50 |
* @throws \Box\Spout\Common\Exception\InvalidArgumentException If the input param is not valid |
| 51 |
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If this function is called before opening the writer |
| 52 |
* @throws \Box\Spout\Common\Exception\IOException If unable to write data |
| 53 |
*/ |
| 54 |
public function addRowWithStyle(array $dataRow, $style); |
| 55 |
|
| 56 |
/** |
| 57 |
* Write given data to the output. New data will be appended to end of stream. |
| 58 |
* |
| 59 |
* @param array $dataRows Array of array containing data to be streamed. |
| 60 |
* Example $dataRow = [ |
| 61 |
* ['data11', 12, , '', 'data13'], |
| 62 |
* ['data21', 'data22', null], |
| 63 |
* ]; |
| 64 |
* @return WriterInterface |
| 65 |
* @throws \Box\Spout\Common\Exception\InvalidArgumentException If the input param is not valid |
| 66 |
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If the writer has not been opened yet |
| 67 |
* @throws \Box\Spout\Common\Exception\IOException If unable to write data |
| 68 |
*/ |
| 69 |
public function addRows(array $dataRows); |
| 70 |
|
| 71 |
/** |
| 72 |
* Write given data to the output and apply the given style. |
| 73 |
* @see addRows |
| 74 |
* |
| 75 |
* @param array $dataRows Array of array containing data to be streamed. |
| 76 |
* @param Style\Style $style Style to be applied to the rows. |
| 77 |
* @return WriterInterface |
| 78 |
* @throws \Box\Spout\Common\Exception\InvalidArgumentException If the input param is not valid |
| 79 |
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If this function is called before opening the writer |
| 80 |
* @throws \Box\Spout\Common\Exception\IOException If unable to write data |
| 81 |
*/ |
| 82 |
public function addRowsWithStyle(array $dataRows, $style); |
| 83 |
|
| 84 |
/** |
| 85 |
* Closes the writer. This will close the streamer as well, preventing new data |
| 86 |
* to be written to the file. |
| 87 |
* |
| 88 |
* @return void |
| 89 |
*/ |
| 90 |
public function close(); |
| 91 |
} |
| 92 |
|