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
@@ -5,6 +5,7 @@ namespace Box\Spout\Writer\CSV;
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Common\Helper\EncodingHelper;
|
||||
use Box\Spout\Writer\Common\Entity\Options;
|
||||
use Box\Spout\Writer\Common\Entity\Row;
|
||||
use Box\Spout\Writer\WriterAbstract;
|
||||
|
||||
/**
|
||||
@@ -78,20 +79,18 @@ class Writer extends WriterAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds data to the currently opened writer.
|
||||
* Adds a row to the currently opened writer.
|
||||
*
|
||||
* @param array $dataRow Array containing data to be written.
|
||||
* Example $dataRow = ['data1', 1234, null, '', 'data5'];
|
||||
* @param \Box\Spout\Writer\Common\Entity\Style\Style $style Ignored here since CSV does not support styling.
|
||||
* @throws \Box\Spout\Common\Exception\IOException If unable to write data
|
||||
* @param Row $row The row containing cells and styles
|
||||
* @throws IOException If unable to write data
|
||||
* @return void
|
||||
*/
|
||||
protected function addRowToWriter(array $dataRow, $style)
|
||||
protected function addRowToWriter(Row $row)
|
||||
{
|
||||
$fieldDelimiter = $this->optionsManager->getOption(Options::FIELD_DELIMITER);
|
||||
$fieldEnclosure = $this->optionsManager->getOption(Options::FIELD_ENCLOSURE);
|
||||
|
||||
$wasWriteSuccessful = $this->globalFunctionsHelper->fputcsv($this->filePointer, $dataRow, $fieldDelimiter, $fieldEnclosure);
|
||||
$wasWriteSuccessful = $this->globalFunctionsHelper->fputcsv($this->filePointer, $row->getCells(), $fieldDelimiter, $fieldEnclosure);
|
||||
if ($wasWriteSuccessful === false) {
|
||||
throw new IOException('Unable to write data');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user