Merge pull request #13 from box/random_fixes

Random fixes
This commit is contained in:
Adrien Loison 2015-04-03 22:24:56 -07:00
commit 09eac62c22
2 changed files with 12 additions and 7 deletions

View File

@ -52,7 +52,7 @@ class CSV extends AbstractReader
* The file must be UTF-8 encoded. * The file must be UTF-8 encoded.
* @TODO add encoding detection/conversion * @TODO add encoding detection/conversion
* *
* @param string $filePath Path of the XLSX file to be read * @param string $filePath Path of the CSV file to be read
* @return void * @return void
* @throws \Box\Spout\Common\Exception\IOException * @throws \Box\Spout\Common\Exception\IOException
*/ */

View File

@ -139,7 +139,8 @@ abstract class AbstractWriter implements WriterInterface
* The data must be UTF-8 encoded. * The data must be UTF-8 encoded.
* *
* @param array $dataRow Array containing data to be streamed. * @param array $dataRow Array containing data to be streamed.
* Example $dataRow = ['data1', 1234, null, '', 'data5']; * If empty, no data is added (i.e. not even as a blank row)
* Example: $dataRow = ['data1', 1234, null, '', 'data5', false];
* *
* @return \Box\Spout\Writer\AbstractWriter * @return \Box\Spout\Writer\AbstractWriter
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If this function is called before opening the writer * @throws \Box\Spout\Writer\Exception\WriterNotOpenedException If this function is called before opening the writer
@ -148,7 +149,10 @@ abstract class AbstractWriter implements WriterInterface
public function addRow(array $dataRow) public function addRow(array $dataRow)
{ {
if ($this->isWriterOpened) { if ($this->isWriterOpened) {
$this->addRowToWriter($dataRow); // empty $dataRow should not add an empty line
if (!empty($dataRow)) {
$this->addRowToWriter($dataRow);
}
} else { } else {
throw new WriterNotOpenedException('The writer needs to be opened before adding row.'); throw new WriterNotOpenedException('The writer needs to be opened before adding row.');
} }
@ -161,10 +165,11 @@ abstract class AbstractWriter implements WriterInterface
* The data must be UTF-8 encoded. * The data must be UTF-8 encoded.
* *
* @param array $dataRows Array of array containing data to be streamed. * @param array $dataRows Array of array containing data to be streamed.
* Example $dataRow = [ * If a row is empty, it won't be added (i.e. not even as a blank row)
* ['data11', 12, , '', 'data13'], * Example: $dataRows = [
* ['data21', 'data22', null], * ['data11', 12, , '', 'data13'],
* ]; * ['data21', 'data22', null, false],
* ];
* *
* @return \Box\Spout\Writer\AbstractWriter * @return \Box\Spout\Writer\AbstractWriter
* @throws \Box\Spout\Common\Exception\InvalidArgumentException If the input param is not valid * @throws \Box\Spout\Common\Exception\InvalidArgumentException If the input param is not valid