rename EntityFactory for writers and readers #526
This commit is contained in:
parent
e1acdc1fc5
commit
8a1c48b6b0
@ -15,11 +15,11 @@ Finally, **_Spout 3.0 only supports PHP 7.1 and above_**, as other PHP versions
|
|||||||
|
|
||||||
Reader changes
|
Reader changes
|
||||||
--------------
|
--------------
|
||||||
Creating a reader should now be done through the Reader `EntityFactory`, instead of using the `ReaderFactory`:
|
Creating a reader should now be done through the Reader `ReaderEntityFactory`, instead of using the `ReaderFactory`:
|
||||||
```php
|
```php
|
||||||
use Box\Spout\Reader\Common\Creator\EntityFactory; // namespace is no longer "Box\Spout\Reader"
|
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory; // namespace is no longer "Box\Spout\Reader"
|
||||||
...
|
...
|
||||||
$reader = EntityFactory::createReader(Type::XLSX);
|
$reader = ReaderEntityFactory::createReader(Type::XLSX);
|
||||||
```
|
```
|
||||||
|
|
||||||
When iterating over the spreadsheet rows, Spout now returns `Row` objects, instead of an array containing row values. Accessing the row values should now be done this way:
|
When iterating over the spreadsheet rows, Spout now returns `Row` objects, instead of an array containing row values. Accessing the row values should now be done this way:
|
||||||
@ -37,23 +37,23 @@ foreach ($reader->getSheetIterator() as $sheet) {
|
|||||||
|
|
||||||
Writer changes
|
Writer changes
|
||||||
--------------
|
--------------
|
||||||
Writer creation follows the same change as the reader. It should now be done through the Writer `EntityFactory`, instead of using the `WriterFactory`:
|
Writer creation follows the same change as the reader. It should now be done through the Writer `WriterEntityFactory`, instead of using the `WriterFactory`:
|
||||||
```php
|
```php
|
||||||
use Box\Spout\Writer\Common\Creator\EntityFactory; // namespace is no longer "Box\Spout\Writer"
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory; // namespace is no longer "Box\Spout\Writer"
|
||||||
...
|
...
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
```
|
```
|
||||||
|
|
||||||
Adding rows is also done differently: instead of passing an array, the writer now takes in a `Row` object (or an array of `Row`). Creating such objects can easily be done this way:
|
Adding rows is also done differently: instead of passing an array, the writer now takes in a `Row` object (or an array of `Row`). Creating such objects can easily be done this way:
|
||||||
```php
|
```php
|
||||||
// Adding a row from an array of values (2.x equivalent)
|
// Adding a row from an array of values (2.x equivalent)
|
||||||
$cellValues = ['foo', 12345];
|
$cellValues = ['foo', 12345];
|
||||||
$row1 = EntityFactory::createRowFromArray($cellValues, $rowStyle);
|
$row1 = WriterEntityFactory::createRowFromArray($cellValues, $rowStyle);
|
||||||
|
|
||||||
// Adding a row from an array of Cell
|
// Adding a row from an array of Cell
|
||||||
$cell1 = EntityFactory::createCell('foo', $cellStyle1); // this cell has its own style
|
$cell1 = WriterEntityFactory::createCell('foo', $cellStyle1); // this cell has its own style
|
||||||
$cell2 = EntityFactory::createCell(12345, $cellStyle2); // this cell has its own style
|
$cell2 = WriterEntityFactory::createCell(12345, $cellStyle2); // this cell has its own style
|
||||||
$row2 = EntityFactory::createRow([$cell1, $cell2]);
|
$row2 = WriterEntityFactory::createRow([$cell1, $cell2]);
|
||||||
|
|
||||||
$writer->addRows([$row1, $row2]);
|
$writer->addRows([$row1, $row2]);
|
||||||
```
|
```
|
||||||
|
@ -5,10 +5,10 @@ namespace Box\Spout\Reader\Common\Creator;
|
|||||||
use Box\Spout\Reader\ReaderInterface;
|
use Box\Spout\Reader\ReaderInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class EntityFactory
|
* Class ReaderEntityFactory
|
||||||
* Factory to create external entities
|
* Factory to create external entities
|
||||||
*/
|
*/
|
||||||
class EntityFactory
|
class ReaderEntityFactory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* This creates an instance of the appropriate reader, given the type of the file to be read
|
* This creates an instance of the appropriate reader, given the type of the file to be read
|
@ -6,7 +6,7 @@ use Box\Spout\Reader\ODS\Helper\CellValueFormatter;
|
|||||||
use Box\Spout\Reader\ODS\Helper\SettingsHelper;
|
use Box\Spout\Reader\ODS\Helper\SettingsHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class EntityFactory
|
* Class HelperFactory
|
||||||
* Factory to create helpers
|
* Factory to create helpers
|
||||||
*/
|
*/
|
||||||
class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
|
class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
|
||||||
|
@ -14,7 +14,7 @@ use Box\Spout\Reader\XLSX\Sheet;
|
|||||||
use Box\Spout\Reader\XLSX\SheetIterator;
|
use Box\Spout\Reader\XLSX\SheetIterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class EntityFactory
|
* Class InternalEntityFactory
|
||||||
* Factory to create entities
|
* Factory to create entities
|
||||||
*/
|
*/
|
||||||
class InternalEntityFactory implements InternalEntityFactoryInterface
|
class InternalEntityFactory implements InternalEntityFactoryInterface
|
||||||
|
@ -8,10 +8,10 @@ use Box\Spout\Common\Entity\Style\Style;
|
|||||||
use Box\Spout\Writer\WriterInterface;
|
use Box\Spout\Writer\WriterInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class EntityFactory
|
* Class WriterEntityFactory
|
||||||
* Factory to create external entities
|
* Factory to create external entities
|
||||||
*/
|
*/
|
||||||
class EntityFactory
|
class WriterEntityFactory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* This creates an instance of the appropriate writer, given the type of the file to be written
|
* This creates an instance of the appropriate writer, given the type of the file to be written
|
@ -3,7 +3,7 @@
|
|||||||
namespace Box\Spout\Reader\CSV;
|
namespace Box\Spout\Reader\CSV;
|
||||||
|
|
||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\Reader\Common\Creator\EntityFactory;
|
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ class SheetTest extends TestCase
|
|||||||
private function openFileAndReturnSheet($fileName)
|
private function openFileAndReturnSheet($fileName)
|
||||||
{
|
{
|
||||||
$resourcePath = $this->getResourcePath($fileName);
|
$resourcePath = $this->getResourcePath($fileName);
|
||||||
$reader = EntityFactory::createReader(Type::CSV);
|
$reader = ReaderEntityFactory::createReader(Type::CSV);
|
||||||
$reader->open($resourcePath);
|
$reader->open($resourcePath);
|
||||||
|
|
||||||
$sheet = $reader->getSheetIterator()->current();
|
$sheet = $reader->getSheetIterator()->current();
|
||||||
|
@ -4,7 +4,7 @@ namespace Box\Spout\Reader\ODS;
|
|||||||
|
|
||||||
use Box\Spout\Common\Exception\IOException;
|
use Box\Spout\Common\Exception\IOException;
|
||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\Reader\Common\Creator\EntityFactory;
|
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||||
use Box\Spout\Reader\Exception\IteratorNotRewindableException;
|
use Box\Spout\Reader\Exception\IteratorNotRewindableException;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@ -354,7 +354,7 @@ class ReaderTest extends TestCase
|
|||||||
$this->expectException(IteratorNotRewindableException::class);
|
$this->expectException(IteratorNotRewindableException::class);
|
||||||
|
|
||||||
$resourcePath = $this->getResourcePath('one_sheet_with_strings.ods');
|
$resourcePath = $this->getResourcePath('one_sheet_with_strings.ods');
|
||||||
$reader = EntityFactory::createReader(Type::ODS);
|
$reader = ReaderEntityFactory::createReader(Type::ODS);
|
||||||
$reader->open($resourcePath);
|
$reader->open($resourcePath);
|
||||||
|
|
||||||
foreach ($reader->getSheetIterator() as $sheet) {
|
foreach ($reader->getSheetIterator() as $sheet) {
|
||||||
@ -379,7 +379,7 @@ class ReaderTest extends TestCase
|
|||||||
$resourcePath = $this->getResourcePath('two_sheets_with_strings.ods');
|
$resourcePath = $this->getResourcePath('two_sheets_with_strings.ods');
|
||||||
|
|
||||||
/** @var Reader $reader */
|
/** @var Reader $reader */
|
||||||
$reader = EntityFactory::createReader(Type::ODS);
|
$reader = ReaderEntityFactory::createReader(Type::ODS);
|
||||||
$reader->open($resourcePath);
|
$reader->open($resourcePath);
|
||||||
|
|
||||||
foreach ($reader->getSheetIterator() as $sheet) {
|
foreach ($reader->getSheetIterator() as $sheet) {
|
||||||
@ -423,7 +423,7 @@ class ReaderTest extends TestCase
|
|||||||
$this->expectException(IOException::class);
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
/** @var \Box\Spout\Reader\ODS\Reader $reader */
|
/** @var \Box\Spout\Reader\ODS\Reader $reader */
|
||||||
$reader = EntityFactory::createReader(Type::ODS);
|
$reader = ReaderEntityFactory::createReader(Type::ODS);
|
||||||
$reader->open('unsupported://foobar');
|
$reader->open('unsupported://foobar');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,7 +435,7 @@ class ReaderTest extends TestCase
|
|||||||
$this->expectException(IOException::class);
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
/** @var \Box\Spout\Reader\ODS\Reader $reader */
|
/** @var \Box\Spout\Reader\ODS\Reader $reader */
|
||||||
$reader = EntityFactory::createReader(Type::ODS);
|
$reader = ReaderEntityFactory::createReader(Type::ODS);
|
||||||
$reader->open('php://memory');
|
$reader->open('php://memory');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,7 +531,7 @@ class ReaderTest extends TestCase
|
|||||||
$resourcePath = $this->getResourcePath($fileName);
|
$resourcePath = $this->getResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Reader\ODS\Reader $reader */
|
/** @var \Box\Spout\Reader\ODS\Reader $reader */
|
||||||
$reader = EntityFactory::createReader(Type::ODS);
|
$reader = ReaderEntityFactory::createReader(Type::ODS);
|
||||||
$reader->setShouldFormatDates($shouldFormatDates);
|
$reader->setShouldFormatDates($shouldFormatDates);
|
||||||
$reader->setShouldPreserveEmptyRows($shouldPreserveEmptyRows);
|
$reader->setShouldPreserveEmptyRows($shouldPreserveEmptyRows);
|
||||||
$reader->open($resourcePath);
|
$reader->open($resourcePath);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace Box\Spout\Reader\ODS;
|
namespace Box\Spout\Reader\ODS;
|
||||||
|
|
||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\Reader\Common\Creator\EntityFactory;
|
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class SheetTest extends TestCase
|
|||||||
private function openFileAndReturnSheets($fileName)
|
private function openFileAndReturnSheets($fileName)
|
||||||
{
|
{
|
||||||
$resourcePath = $this->getResourcePath($fileName);
|
$resourcePath = $this->getResourcePath($fileName);
|
||||||
$reader = EntityFactory::createReader(Type::ODS);
|
$reader = ReaderEntityFactory::createReader(Type::ODS);
|
||||||
$reader->open($resourcePath);
|
$reader->open($resourcePath);
|
||||||
|
|
||||||
$sheets = [];
|
$sheets = [];
|
||||||
|
@ -4,7 +4,7 @@ namespace Box\Spout\Reader\XLSX;
|
|||||||
|
|
||||||
use Box\Spout\Common\Exception\IOException;
|
use Box\Spout\Common\Exception\IOException;
|
||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\Reader\Common\Creator\EntityFactory;
|
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
@ -570,7 +570,7 @@ class ReaderTest extends TestCase
|
|||||||
$allRows = [];
|
$allRows = [];
|
||||||
$resourcePath = $this->getResourcePath('two_sheets_with_inline_strings.xlsx');
|
$resourcePath = $this->getResourcePath('two_sheets_with_inline_strings.xlsx');
|
||||||
|
|
||||||
$reader = EntityFactory::createReader(Type::XLSX);
|
$reader = ReaderEntityFactory::createReader(Type::XLSX);
|
||||||
$reader->open($resourcePath);
|
$reader->open($resourcePath);
|
||||||
|
|
||||||
foreach ($reader->getSheetIterator() as $sheet) {
|
foreach ($reader->getSheetIterator() as $sheet) {
|
||||||
@ -624,7 +624,7 @@ class ReaderTest extends TestCase
|
|||||||
$this->expectException(IOException::class);
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
/** @var \Box\Spout\Reader\XLSX\Reader $reader */
|
/** @var \Box\Spout\Reader\XLSX\Reader $reader */
|
||||||
$reader = EntityFactory::createReader(Type::XLSX);
|
$reader = ReaderEntityFactory::createReader(Type::XLSX);
|
||||||
$reader->open('unsupported://foobar');
|
$reader->open('unsupported://foobar');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -636,7 +636,7 @@ class ReaderTest extends TestCase
|
|||||||
$this->expectException(IOException::class);
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
/** @var \Box\Spout\Reader\XLSX\Reader $reader */
|
/** @var \Box\Spout\Reader\XLSX\Reader $reader */
|
||||||
$reader = EntityFactory::createReader(Type::XLSX);
|
$reader = ReaderEntityFactory::createReader(Type::XLSX);
|
||||||
$reader->open('php://memory');
|
$reader->open('php://memory');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,7 +701,7 @@ class ReaderTest extends TestCase
|
|||||||
$resourcePath = $this->getResourcePath($fileName);
|
$resourcePath = $this->getResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Reader\XLSX\Reader $reader */
|
/** @var \Box\Spout\Reader\XLSX\Reader $reader */
|
||||||
$reader = EntityFactory::createReader(Type::XLSX);
|
$reader = ReaderEntityFactory::createReader(Type::XLSX);
|
||||||
$reader->setShouldFormatDates($shouldFormatDates);
|
$reader->setShouldFormatDates($shouldFormatDates);
|
||||||
$reader->setShouldPreserveEmptyRows($shouldPreserveEmptyRows);
|
$reader->setShouldPreserveEmptyRows($shouldPreserveEmptyRows);
|
||||||
$reader->open($resourcePath);
|
$reader->open($resourcePath);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace Box\Spout\Reader\XLSX;
|
namespace Box\Spout\Reader\XLSX;
|
||||||
|
|
||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\Reader\Common\Creator\EntityFactory;
|
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ class SheetTest extends TestCase
|
|||||||
private function openFileAndReturnSheets($fileName)
|
private function openFileAndReturnSheets($fileName)
|
||||||
{
|
{
|
||||||
$resourcePath = $this->getResourcePath($fileName);
|
$resourcePath = $this->getResourcePath($fileName);
|
||||||
$reader = EntityFactory::createReader(Type::XLSX);
|
$reader = ReaderEntityFactory::createReader(Type::XLSX);
|
||||||
$reader->open($resourcePath);
|
$reader->open($resourcePath);
|
||||||
|
|
||||||
$sheets = [];
|
$sheets = [];
|
||||||
|
@ -8,7 +8,7 @@ use Box\Spout\Common\Exception\IOException;
|
|||||||
use Box\Spout\Common\Helper\EncodingHelper;
|
use Box\Spout\Common\Helper\EncodingHelper;
|
||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@ -32,7 +32,7 @@ class WriterTest extends TestCase
|
|||||||
$this->createUnwritableFolderIfNeeded();
|
$this->createUnwritableFolderIfNeeded();
|
||||||
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::CSV);
|
$writer = WriterEntityFactory::createWriter(Type::CSV);
|
||||||
@$writer->openToFile($filePath);
|
@$writer->openToFile($filePath);
|
||||||
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
||||||
$writer->close();
|
$writer->close();
|
||||||
@ -45,7 +45,7 @@ class WriterTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(WriterNotOpenedException::class);
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::CSV);
|
$writer = WriterEntityFactory::createWriter(Type::CSV);
|
||||||
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
||||||
$writer->close();
|
$writer->close();
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ class WriterTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(WriterNotOpenedException::class);
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::CSV);
|
$writer = WriterEntityFactory::createWriter(Type::CSV);
|
||||||
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
||||||
$writer->close();
|
$writer->close();
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ class WriterTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(InvalidArgumentException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::CSV);
|
$writer = WriterEntityFactory::createWriter(Type::CSV);
|
||||||
$writer->addRows([['csv--11', 'csv--12']]);
|
$writer->addRows([['csv--11', 'csv--12']]);
|
||||||
$writer->close();
|
$writer->close();
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ class WriterTest extends TestCase
|
|||||||
$this->createGeneratedFolderIfNeeded($fileName);
|
$this->createGeneratedFolderIfNeeded($fileName);
|
||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::CSV);
|
$writer = WriterEntityFactory::createWriter(Type::CSV);
|
||||||
$writer->close(); // This call should not cause any error
|
$writer->close(); // This call should not cause any error
|
||||||
|
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
@ -202,7 +202,7 @@ class WriterTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\CSV\Writer $writer */
|
/** @var \Box\Spout\Writer\CSV\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::CSV);
|
$writer = WriterEntityFactory::createWriter(Type::CSV);
|
||||||
$writer->setFieldDelimiter($fieldDelimiter);
|
$writer->setFieldDelimiter($fieldDelimiter);
|
||||||
$writer->setFieldEnclosure($fieldEnclosure);
|
$writer->setFieldEnclosure($fieldEnclosure);
|
||||||
$writer->setShouldAddBOM($shouldAddBOM);
|
$writer->setShouldAddBOM($shouldAddBOM);
|
||||||
|
@ -4,7 +4,7 @@ namespace Box\Spout\Writer\ODS;
|
|||||||
|
|
||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
use Box\Spout\Writer\Common\Entity\Sheet;
|
use Box\Spout\Writer\Common\Entity\Sheet;
|
||||||
use Box\Spout\Writer\Exception\InvalidSheetNameException;
|
use Box\Spout\Writer\Exception\InvalidSheetNameException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
@ -66,7 +66,7 @@ class SheetTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
|
||||||
$customSheetName = 'Sheet name';
|
$customSheetName = 'Sheet name';
|
||||||
@ -105,7 +105,7 @@ class SheetTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
|
||||||
$sheet = $writer->getCurrentSheet();
|
$sheet = $writer->getCurrentSheet();
|
||||||
@ -125,7 +125,7 @@ class SheetTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
|
||||||
$writer->addRow($this->createRowFromValues(['ods--sheet1--11', 'ods--sheet1--12']));
|
$writer->addRow($this->createRowFromValues(['ods--sheet1--11', 'ods--sheet1--12']));
|
||||||
@ -147,7 +147,7 @@ class SheetTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
|
||||||
$sheet = $writer->getCurrentSheet();
|
$sheet = $writer->getCurrentSheet();
|
||||||
|
@ -9,7 +9,7 @@ use Box\Spout\Common\Exception\SpoutException;
|
|||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\Reader\Wrapper\XMLReader;
|
use Box\Spout\Reader\Wrapper\XMLReader;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
use Box\Spout\Writer\Exception\WriterAlreadyOpenedException;
|
use Box\Spout\Writer\Exception\WriterAlreadyOpenedException;
|
||||||
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
@ -34,7 +34,7 @@ class WriterTest extends TestCase
|
|||||||
$this->createUnwritableFolderIfNeeded();
|
$this->createUnwritableFolderIfNeeded();
|
||||||
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
@$writer->openToFile($filePath);
|
@$writer->openToFile($filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class WriterTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(WriterNotOpenedException::class);
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->addRow($this->createRowFromValues(['ods--11', 'ods--12']));
|
$writer->addRow($this->createRowFromValues(['ods--11', 'ods--12']));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class WriterTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(WriterNotOpenedException::class);
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->addRows([$this->createRowFromValues(['ods--11', 'ods--12'])]);
|
$writer->addRows([$this->createRowFromValues(['ods--11', 'ods--12'])]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class WriterTest extends TestCase
|
|||||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->openToFile($filePath);
|
$writer->openToFile($filePath);
|
||||||
|
|
||||||
$writer->setTempFolder('');
|
$writer->setTempFolder('');
|
||||||
@ -88,7 +88,7 @@ class WriterTest extends TestCase
|
|||||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->openToFile($filePath);
|
$writer->openToFile($filePath);
|
||||||
|
|
||||||
$writer->setShouldCreateNewSheetsAutomatically(true);
|
$writer->setShouldCreateNewSheetsAutomatically(true);
|
||||||
@ -127,7 +127,7 @@ class WriterTest extends TestCase
|
|||||||
$tempFolderPath = $this->getTempFolderPath();
|
$tempFolderPath = $this->getTempFolderPath();
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->setTempFolder($tempFolderPath);
|
$writer->setTempFolder($tempFolderPath);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ class WriterTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var Writer $writer */
|
/** @var Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
$writer->addNewSheetAndMakeItCurrent();
|
$writer->addNewSheetAndMakeItCurrent();
|
||||||
$writer->close();
|
$writer->close();
|
||||||
@ -172,7 +172,7 @@ class WriterTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var Writer $writer */
|
/** @var Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
|
||||||
$writer->addNewSheetAndMakeItCurrent();
|
$writer->addNewSheetAndMakeItCurrent();
|
||||||
@ -195,7 +195,7 @@ class WriterTest extends TestCase
|
|||||||
$this->createGeneratedFolderIfNeeded($fileName);
|
$this->createGeneratedFolderIfNeeded($fileName);
|
||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->close(); // This call should not cause any error
|
$writer->close(); // This call should not cause any error
|
||||||
|
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
@ -350,7 +350,7 @@ class WriterTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
|
||||||
$writer->addRows($dataRowsSheet1);
|
$writer->addRows($dataRowsSheet1);
|
||||||
@ -486,7 +486,7 @@ class WriterTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->setShouldCreateNewSheetsAutomatically($shouldCreateSheetsAutomatically);
|
$writer->setShouldCreateNewSheetsAutomatically($shouldCreateSheetsAutomatically);
|
||||||
|
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
@ -509,7 +509,7 @@ class WriterTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->setShouldCreateNewSheetsAutomatically($shouldCreateSheetsAutomatically);
|
$writer->setShouldCreateNewSheetsAutomatically($shouldCreateSheetsAutomatically);
|
||||||
|
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
@ -9,9 +9,9 @@ use Box\Spout\Common\Entity\Style\Style;
|
|||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\Reader\Wrapper\XMLReader;
|
use Box\Spout\Reader\Wrapper\XMLReader;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
|
||||||
use Box\Spout\Writer\Common\Creator\Style\BorderBuilder;
|
use Box\Spout\Writer\Common\Creator\Style\BorderBuilder;
|
||||||
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
|
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
|
||||||
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@ -42,7 +42,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(WriterNotOpenedException::class);
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->addRow($this->createStyledRowFromValues(['ods--11', 'ods--12'], $this->defaultStyle));
|
$writer->addRow($this->createStyledRowFromValues(['ods--11', 'ods--12'], $this->defaultStyle));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(WriterNotOpenedException::class);
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->addRow($this->createStyledRowFromValues(['ods--11', 'ods--12'], $this->defaultStyle));
|
$writer->addRow($this->createStyledRowFromValues(['ods--11', 'ods--12'], $this->defaultStyle));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,10 +215,10 @@ class WriterWithStyleTest extends TestCase
|
|||||||
$boldStyle = (new StyleBuilder())->setFontBold()->build();
|
$boldStyle = (new StyleBuilder())->setFontBold()->build();
|
||||||
$underlineStyle = (new StyleBuilder())->setFontUnderline()->build();
|
$underlineStyle = (new StyleBuilder())->setFontUnderline()->build();
|
||||||
|
|
||||||
$dataRow = EntityFactory::createRow([
|
$dataRow = WriterEntityFactory::createRow([
|
||||||
EntityFactory::createCell('ods--11', $boldStyle),
|
WriterEntityFactory::createCell('ods--11', $boldStyle),
|
||||||
EntityFactory::createCell('ods--12', $underlineStyle),
|
WriterEntityFactory::createCell('ods--12', $underlineStyle),
|
||||||
EntityFactory::createCell('ods--13', $underlineStyle),
|
WriterEntityFactory::createCell('ods--13', $underlineStyle),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->writeToODSFile([$dataRow], $fileName);
|
$this->writeToODSFile([$dataRow], $fileName);
|
||||||
@ -347,7 +347,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
|
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
$writer->addRows($allRows);
|
$writer->addRows($allRows);
|
||||||
@ -368,7 +368,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
/** @var \Box\Spout\Writer\ODS\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::ODS);
|
$writer = WriterEntityFactory::createWriter(Type::ODS);
|
||||||
$writer->setDefaultRowStyle($defaultStyle);
|
$writer->setDefaultRowStyle($defaultStyle);
|
||||||
|
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
@ -4,7 +4,7 @@ namespace Box\Spout\Writer;
|
|||||||
|
|
||||||
use Box\Spout\Common\Entity\Row;
|
use Box\Spout\Common\Entity\Row;
|
||||||
use Box\Spout\Common\Entity\Style\Style;
|
use Box\Spout\Common\Entity\Style\Style;
|
||||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trait RowCreationHelper
|
* Trait RowCreationHelper
|
||||||
@ -27,7 +27,7 @@ trait RowCreationHelper
|
|||||||
*/
|
*/
|
||||||
protected function createStyledRowFromValues(array $cellValues, Style $rowStyle = null)
|
protected function createStyledRowFromValues(array $cellValues, Style $rowStyle = null)
|
||||||
{
|
{
|
||||||
return EntityFactory::createRowFromArray($cellValues, $rowStyle);
|
return WriterEntityFactory::createRowFromArray($cellValues, $rowStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,7 @@ namespace Box\Spout\Writer\XLSX;
|
|||||||
|
|
||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
use Box\Spout\Writer\Common\Entity\Sheet;
|
use Box\Spout\Writer\Common\Entity\Sheet;
|
||||||
use Box\Spout\Writer\Exception\InvalidSheetNameException;
|
use Box\Spout\Writer\Exception\InvalidSheetNameException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
@ -66,7 +66,7 @@ class SheetTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
|
||||||
$customSheetName = 'Sheet name';
|
$customSheetName = 'Sheet name';
|
||||||
@ -105,7 +105,7 @@ class SheetTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
|
||||||
$sheet = $writer->getCurrentSheet();
|
$sheet = $writer->getCurrentSheet();
|
||||||
@ -127,7 +127,7 @@ class SheetTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
|
||||||
$writer->addRow($this->createRowFromValues(['xlsx--sheet1--11', 'xlsx--sheet1--12']));
|
$writer->addRow($this->createRowFromValues(['xlsx--sheet1--11', 'xlsx--sheet1--12']));
|
||||||
@ -149,7 +149,7 @@ class SheetTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
|
||||||
$sheet = $writer->getCurrentSheet();
|
$sheet = $writer->getCurrentSheet();
|
||||||
|
@ -8,7 +8,7 @@ use Box\Spout\Common\Exception\IOException;
|
|||||||
use Box\Spout\Common\Exception\SpoutException;
|
use Box\Spout\Common\Exception\SpoutException;
|
||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
use Box\Spout\Writer\Exception\WriterAlreadyOpenedException;
|
use Box\Spout\Writer\Exception\WriterAlreadyOpenedException;
|
||||||
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
@ -34,7 +34,7 @@ class WriterTest extends TestCase
|
|||||||
$this->createUnwritableFolderIfNeeded();
|
$this->createUnwritableFolderIfNeeded();
|
||||||
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
@$writer->openToFile($filePath);
|
@$writer->openToFile($filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class WriterTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(WriterNotOpenedException::class);
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->addRow($this->createRowFromValues(['xlsx--11', 'xlsx--12']));
|
$writer->addRow($this->createRowFromValues(['xlsx--11', 'xlsx--12']));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class WriterTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(WriterNotOpenedException::class);
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->addRows($this->createRowsFromValues([['xlsx--11', 'xlsx--12']]));
|
$writer->addRows($this->createRowsFromValues([['xlsx--11', 'xlsx--12']]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class WriterTest extends TestCase
|
|||||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->openToFile($filePath);
|
$writer->openToFile($filePath);
|
||||||
|
|
||||||
$writer->setTempFolder('');
|
$writer->setTempFolder('');
|
||||||
@ -88,7 +88,7 @@ class WriterTest extends TestCase
|
|||||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->openToFile($filePath);
|
$writer->openToFile($filePath);
|
||||||
|
|
||||||
$writer->setShouldUseInlineStrings(true);
|
$writer->setShouldUseInlineStrings(true);
|
||||||
@ -105,7 +105,7 @@ class WriterTest extends TestCase
|
|||||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->openToFile($filePath);
|
$writer->openToFile($filePath);
|
||||||
|
|
||||||
$writer->setShouldCreateNewSheetsAutomatically(true);
|
$writer->setShouldCreateNewSheetsAutomatically(true);
|
||||||
@ -159,7 +159,7 @@ class WriterTest extends TestCase
|
|||||||
$tempFolderPath = $this->getTempFolderPath();
|
$tempFolderPath = $this->getTempFolderPath();
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->setTempFolder($tempFolderPath);
|
$writer->setTempFolder($tempFolderPath);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ class WriterTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
$writer->addNewSheetAndMakeItCurrent();
|
$writer->addNewSheetAndMakeItCurrent();
|
||||||
$writer->close();
|
$writer->close();
|
||||||
@ -204,7 +204,7 @@ class WriterTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
|
|
||||||
$writer->addNewSheetAndMakeItCurrent();
|
$writer->addNewSheetAndMakeItCurrent();
|
||||||
@ -227,7 +227,7 @@ class WriterTest extends TestCase
|
|||||||
$this->createGeneratedFolderIfNeeded($fileName);
|
$this->createGeneratedFolderIfNeeded($fileName);
|
||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->close(); // This call should not cause any error
|
$writer->close(); // This call should not cause any error
|
||||||
|
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
@ -405,7 +405,7 @@ class WriterTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->setShouldUseInlineStrings(true);
|
$writer->setShouldUseInlineStrings(true);
|
||||||
|
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
@ -545,7 +545,7 @@ class WriterTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->setShouldUseInlineStrings($shouldUseInlineStrings);
|
$writer->setShouldUseInlineStrings($shouldUseInlineStrings);
|
||||||
$writer->setShouldCreateNewSheetsAutomatically($shouldCreateSheetsAutomatically);
|
$writer->setShouldCreateNewSheetsAutomatically($shouldCreateSheetsAutomatically);
|
||||||
|
|
||||||
@ -570,7 +570,7 @@ class WriterTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->setShouldUseInlineStrings($shouldUseInlineStrings);
|
$writer->setShouldUseInlineStrings($shouldUseInlineStrings);
|
||||||
$writer->setShouldCreateNewSheetsAutomatically($shouldCreateSheetsAutomatically);
|
$writer->setShouldCreateNewSheetsAutomatically($shouldCreateSheetsAutomatically);
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ use Box\Spout\Common\Entity\Style\Style;
|
|||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\Reader\Wrapper\XMLReader;
|
use Box\Spout\Reader\Wrapper\XMLReader;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
|
||||||
use Box\Spout\Writer\Common\Creator\Style\BorderBuilder;
|
use Box\Spout\Writer\Common\Creator\Style\BorderBuilder;
|
||||||
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
|
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
|
||||||
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
|
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
|
||||||
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
@ -45,7 +45,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(WriterNotOpenedException::class);
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->addRow($this->createStyledRowFromValues(['xlsx--11', 'xlsx--12'], $this->defaultStyle));
|
$writer->addRow($this->createStyledRowFromValues(['xlsx--11', 'xlsx--12'], $this->defaultStyle));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(WriterNotOpenedException::class);
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->addRow($this->createStyledRowFromValues(['xlsx--11', 'xlsx--12'], $this->defaultStyle));
|
$writer->addRow($this->createStyledRowFromValues(['xlsx--11', 'xlsx--12'], $this->defaultStyle));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,10 +262,10 @@ class WriterWithStyleTest extends TestCase
|
|||||||
$boldStyle = (new StyleBuilder())->setFontBold()->build();
|
$boldStyle = (new StyleBuilder())->setFontBold()->build();
|
||||||
$underlineStyle = (new StyleBuilder())->setFontUnderline()->build();
|
$underlineStyle = (new StyleBuilder())->setFontUnderline()->build();
|
||||||
|
|
||||||
$dataRow = EntityFactory::createRow([
|
$dataRow = WriterEntityFactory::createRow([
|
||||||
EntityFactory::createCell('xlsx--11', $boldStyle),
|
WriterEntityFactory::createCell('xlsx--11', $boldStyle),
|
||||||
EntityFactory::createCell('xlsx--12', $underlineStyle),
|
WriterEntityFactory::createCell('xlsx--12', $underlineStyle),
|
||||||
EntityFactory::createCell('xlsx--13', $underlineStyle),
|
WriterEntityFactory::createCell('xlsx--13', $underlineStyle),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->writeToXLSXFile([$dataRow], $fileName);
|
$this->writeToXLSXFile([$dataRow], $fileName);
|
||||||
@ -519,7 +519,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->setShouldUseInlineStrings(true);
|
$writer->setShouldUseInlineStrings(true);
|
||||||
|
|
||||||
$writer->openToFile($resourcePath);
|
$writer->openToFile($resourcePath);
|
||||||
@ -541,7 +541,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||||
$writer = EntityFactory::createWriter(Type::XLSX);
|
$writer = WriterEntityFactory::createWriter(Type::XLSX);
|
||||||
$writer->setShouldUseInlineStrings(true);
|
$writer->setShouldUseInlineStrings(true);
|
||||||
$writer->setDefaultRowStyle($defaultStyle);
|
$writer->setDefaultRowStyle($defaultStyle);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user