Row objects and Cell styling
This commit introduces Row and Cell entities, that will replace the arrays passed in previously. It also adds support for Cell styling (instead of Row styling only).
This commit is contained in:
1 parent
fec27e9056
commit
7274226b75
32 files changed
+1113
-859
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Box\Spout\Writer;
|
||||
|
||||
use Box\Spout\Writer\Common\Entity\Row;
|
||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
|
||||
/**
|
||||
@@ -10,7 +11,7 @@ use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
interface WriterInterface
|
||||
{
|
||||
/**
|
||||
* Inits the writer and opens it to accept data.
|
||||
* Initializes the writer and opens it to accept data.
|
||||
* By using this method, the data will be written to a file.
|
||||
*
|
||||
* @param string $outputFilePath Path of the output file that will contain the data
|
||||
@@ -20,7 +21,7 @@ interface WriterInterface
|
||||
public function openToFile($outputFilePath);
|
||||
|
||||
/**
|
||||
* Inits the writer and opens it to accept data.
|
||||
* Initializes the writer and opens it to accept data.
|
||||
* By using this method, the data will be outputted directly to the browser.
|
||||
*
|
||||
* @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,56 +31,35 @@ interface WriterInterface
|
||||
public function openToBrowser($outputFileName);
|
||||
|
||||
/**
|
||||
* Write given data to the output. New data will be appended to end of stream.
|
||||
* Sets the default styles for all rows added with "addRow".
|
||||
* Overriding the default style instead of using "addRowWithStyle" improves performance by 20%.
|
||||
* @see https://github.com/box/spout/issues/272
|
||||
*
|
||||
* @param array $dataRow Array containing data to be streamed.
|
||||
* Example $dataRow = ['data1', 1234, null, '', 'data5'];
|
||||
* @param Style $defaultStyle
|
||||
* @return WriterInterface
|
||||
*/
|
||||
public function setDefaultRowStyle(Style $defaultStyle);
|
||||
|
||||
/**
|
||||
* Appends a row to the end of the stream.
|
||||
*
|
||||
* @param Row $row The row to be appended to the stream
|
||||
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If the writer has not been opened yetthe writer
|
||||
* @throws \Box\Spout\Common\Exception\IOException If unable to write data
|
||||
* @return WriterInterface
|
||||
*/
|
||||
public function addRow(array $dataRow);
|
||||
public function addRow(Row $row);
|
||||
|
||||
/**
|
||||
* Write given data to the output and apply the given style.
|
||||
* @see addRow
|
||||
* Appends the rows to the end of the stream.
|
||||
*
|
||||
* @param array $dataRow Array of array containing data to be streamed.
|
||||
* @param Style $style Style to be applied to the row.
|
||||
* @throws \Box\Spout\Common\Exception\InvalidArgumentException If the input param is not valid
|
||||
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If this function is called before opening the writer
|
||||
* @throws \Box\Spout\Common\Exception\IOException If unable to write data
|
||||
* @return WriterInterface
|
||||
*/
|
||||
public function addRowWithStyle(array $dataRow, $style);
|
||||
|
||||
/**
|
||||
* Write given data to the output. New data will be appended to end of stream.
|
||||
*
|
||||
* @param array $dataRows Array of array containing data to be streamed.
|
||||
* Example $dataRow = [
|
||||
* ['data11', 12, , '', 'data13'],
|
||||
* ['data21', 'data22', null],
|
||||
* ];
|
||||
* @param Row[] $rows The rows to be appended to the stream
|
||||
* @throws \Box\Spout\Common\Exception\InvalidArgumentException If the input param is not valid
|
||||
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If the writer has not been opened yet
|
||||
* @throws \Box\Spout\Common\Exception\IOException If unable to write data
|
||||
* @return WriterInterface
|
||||
*/
|
||||
public function addRows(array $dataRows);
|
||||
|
||||
/**
|
||||
* Write given data to the output and apply the given style.
|
||||
* @see addRows
|
||||
*
|
||||
* @param array $dataRows Array of array containing data to be streamed.
|
||||
* @param Style $style Style to be applied to the rows.
|
||||
* @throws \Box\Spout\Common\Exception\InvalidArgumentException If the input param is not valid
|
||||
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If this function is called before opening the writer
|
||||
* @throws \Box\Spout\Common\Exception\IOException If unable to write data
|
||||
* @return WriterInterface
|
||||
*/
|
||||
public function addRowsWithStyle(array $dataRows, $style);
|
||||
public function addRows(array $rows);
|
||||
|
||||
/**
|
||||
* Closes the writer. This will close the streamer as well, preventing new data
|
||||
|
||||
Reference in new issue
Block a user