Update Writer folder structure to match Reader new structure
This commit is contained in:
parent
c52dd7bde8
commit
c672558a18
@ -69,7 +69,7 @@ abstract class AbstractWriter implements WriterInterface
|
||||
* 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
|
||||
* @return \Box\Spout\Writer\AbstractWriter
|
||||
* @return AbstractWriter
|
||||
* @throws \Box\Spout\Common\Exception\IOException If the writer cannot be opened or if the given path is not writable
|
||||
*/
|
||||
public function openToFile($outputFilePath)
|
||||
@ -92,7 +92,7 @@ abstract class AbstractWriter implements WriterInterface
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @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
|
||||
* @return \Box\Spout\Writer\AbstractWriter
|
||||
* @return AbstractWriter
|
||||
* @throws \Box\Spout\Common\Exception\IOException If the writer cannot be opened
|
||||
*/
|
||||
public function openToBrowser($outputFileName)
|
||||
@ -144,7 +144,7 @@ abstract class AbstractWriter implements WriterInterface
|
||||
* 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 AbstractWriter
|
||||
* @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
|
||||
*/
|
||||
@ -173,7 +173,7 @@ abstract class AbstractWriter implements WriterInterface
|
||||
* ['data21', 'data22', null, false],
|
||||
* ];
|
||||
*
|
||||
* @return \Box\Spout\Writer\AbstractWriter
|
||||
* @return AbstractWriter
|
||||
* @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
|
||||
|
@ -1,16 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer;
|
||||
namespace Box\Spout\Writer\CSV;
|
||||
|
||||
use Box\Spout\Writer\AbstractWriter;
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
|
||||
/**
|
||||
* Class CSV
|
||||
* Class Writer
|
||||
* This class provides support to write data to CSV files
|
||||
*
|
||||
* @package Box\Spout\Writer
|
||||
* @package Box\Spout\Writer\CSV
|
||||
*/
|
||||
class CSV extends AbstractWriter
|
||||
class Writer extends AbstractWriter
|
||||
{
|
||||
/** Number of rows to write before flushing */
|
||||
const FLUSH_THRESHOLD = 500;
|
||||
@ -32,7 +33,7 @@ class CSV extends AbstractWriter
|
||||
* Sets the field delimiter for the CSV
|
||||
*
|
||||
* @param string $fieldDelimiter Character that delimits fields
|
||||
* @return CSV
|
||||
* @return Writer
|
||||
*/
|
||||
public function setFieldDelimiter($fieldDelimiter)
|
||||
{
|
||||
@ -44,7 +45,7 @@ class CSV extends AbstractWriter
|
||||
* Sets the field enclosure for the CSV
|
||||
*
|
||||
* @param string $fieldEnclosure Character that enclose fields
|
||||
* @return CSV
|
||||
* @return Writer
|
||||
*/
|
||||
public function setFieldEnclosure($fieldEnclosure)
|
||||
{
|
@ -19,7 +19,7 @@ class WriterFactory
|
||||
* This creates an instance of the appropriate writer, given the type of the file to be read
|
||||
*
|
||||
* @param string $writerType Type of the writer to instantiate
|
||||
* @return \Box\Spout\Writer\CSV|\Box\Spout\Writer\XLSX
|
||||
* @return \Box\Spout\Writer\CSV\Writer|\Box\Spout\Writer\XLSX\Writer
|
||||
* @throws \Box\Spout\Common\Exception\UnsupportedTypeException
|
||||
*/
|
||||
public static function create($writerType)
|
||||
@ -28,10 +28,10 @@ class WriterFactory
|
||||
|
||||
switch ($writerType) {
|
||||
case Type::CSV:
|
||||
$writer = new CSV();
|
||||
$writer = new CSV\Writer();
|
||||
break;
|
||||
case Type::XLSX:
|
||||
$writer = new XLSX();
|
||||
$writer = new XLSX\Writer();
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedTypeException('No writers supporting the given type: ' . $writerType);
|
||||
|
@ -14,7 +14,7 @@ interface WriterInterface
|
||||
* 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
|
||||
* @return \Box\Spout\Writer\WriterInterface
|
||||
* @return WriterInterface
|
||||
* @throws \Box\Spout\Common\Exception\IOException If the writer cannot be opened or if the given path is not writable
|
||||
*/
|
||||
public function openToFile($outputFilePath);
|
||||
@ -24,7 +24,7 @@ interface WriterInterface
|
||||
* 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
|
||||
* @return \Box\Spout\Writer\WriterInterface
|
||||
* @return WriterInterface
|
||||
* @throws \Box\Spout\Common\Exception\IOException If the writer cannot be opened
|
||||
*/
|
||||
public function openToBrowser($outputFileName);
|
||||
@ -34,7 +34,7 @@ interface WriterInterface
|
||||
*
|
||||
* @param array $dataRow Array containing data to be streamed.
|
||||
* Example $dataRow = ['data1', 1234, null, '', 'data5'];
|
||||
* @return \Box\Spout\Writer\WriterInterface
|
||||
* @return WriterInterface
|
||||
* @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
|
||||
*/
|
||||
@ -48,7 +48,7 @@ interface WriterInterface
|
||||
* ['data11', 12, , '', 'data13'],
|
||||
* ['data21', 'data22', null],
|
||||
* ];
|
||||
* @return \Box\Spout\Writer\WriterInterface
|
||||
* @return WriterInterface
|
||||
* @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
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer\Helper\XLSX;
|
||||
namespace Box\Spout\Writer\XLSX\Helper;
|
||||
|
||||
/**
|
||||
* Class CellHelper
|
||||
* This class provides helper functions when working with cells
|
||||
*
|
||||
* @package Box\Spout\Writer\Helper\XLSX
|
||||
* @package Box\Spout\Writer\XLSX\Helper
|
||||
*/
|
||||
class CellHelper
|
||||
{
|
@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer\Helper\XLSX;
|
||||
namespace Box\Spout\Writer\XLSX\Helper;
|
||||
|
||||
use Box\Spout\Writer\Internal\XLSX\Worksheet;
|
||||
use Box\Spout\Writer\XLSX\Internal\Worksheet;
|
||||
|
||||
/**
|
||||
* Class FileSystemHelper
|
||||
* This class provides helper functions to help with the file system operations
|
||||
* like files/folders creation & deletion for XLSX files
|
||||
*
|
||||
* @package Box\Spout\Writer\Helper\XLSX
|
||||
* @package Box\Spout\Writer\XLSX\Helper
|
||||
*/
|
||||
class FileSystemHelper extends \Box\Spout\Common\Helper\FileSystemHelper
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer\Helper\XLSX;
|
||||
namespace Box\Spout\Writer\XLSX\Helper;
|
||||
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
|
||||
@ -8,7 +8,7 @@ use Box\Spout\Common\Exception\IOException;
|
||||
* Class SharedStringsHelper
|
||||
* This class provides helper functions to write shared strings
|
||||
*
|
||||
* @package Box\Spout\Writer\Helper\XLSX
|
||||
* @package Box\Spout\Writer\XLSX\Helper
|
||||
*/
|
||||
class SharedStringsHelper
|
||||
{
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer\Helper\XLSX;
|
||||
namespace Box\Spout\Writer\XLSX\Helper;
|
||||
|
||||
/**
|
||||
* Class ZipHelper
|
||||
* This class provides helper functions to create zip files
|
||||
*
|
||||
* @package Box\Spout\Writer\Helper\XLSX
|
||||
* @package Box\Spout\Writer\XLSX\Helper
|
||||
*/
|
||||
class ZipHelper
|
||||
{
|
@ -1,18 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer\Internal\XLSX;
|
||||
namespace Box\Spout\Writer\XLSX\Internal;
|
||||
|
||||
use Box\Spout\Writer\Exception\SheetNotFoundException;
|
||||
use Box\Spout\Writer\Helper\XLSX\FileSystemHelper;
|
||||
use Box\Spout\Writer\Helper\XLSX\SharedStringsHelper;
|
||||
use Box\Spout\Writer\Sheet;
|
||||
use Box\Spout\Writer\XLSX\Helper\FileSystemHelper;
|
||||
use Box\Spout\Writer\XLSX\Helper\SharedStringsHelper;
|
||||
use Box\Spout\Writer\XLSX\Sheet;
|
||||
|
||||
/**
|
||||
* Class Book
|
||||
* Represents a workbook within a XLSX file.
|
||||
* It provides the functions to work with worksheets.
|
||||
*
|
||||
* @package Box\Spout\Writer\Internal\XLSX
|
||||
* @package Box\Spout\Writer\XLSX\Internal
|
||||
*/
|
||||
class Workbook
|
||||
{
|
||||
@ -28,10 +28,10 @@ class Workbook
|
||||
/** @var bool Whether new sheets should be automatically created when the max rows limit per sheet is reached */
|
||||
protected $shouldCreateNewSheetsAutomatically;
|
||||
|
||||
/** @var \Box\Spout\Writer\Helper\XLSX\FileSystemHelper Helper to perform file system operations */
|
||||
/** @var \Box\Spout\Writer\XLSX\Helper\FileSystemHelper Helper to perform file system operations */
|
||||
protected $fileSystemHelper;
|
||||
|
||||
/** @var \Box\Spout\Writer\Helper\XLSX\SharedStringsHelper Helper to write shared strings */
|
||||
/** @var \Box\Spout\Writer\XLSX\Helper\SharedStringsHelper Helper to write shared strings */
|
||||
protected $sharedStringsHelper;
|
||||
|
||||
/** @var Worksheet[] Array containing the workbook's sheets */
|
||||
@ -114,7 +114,7 @@ class Workbook
|
||||
* Sets the given sheet as the current one. New data will be written to this sheet.
|
||||
* The writing will resume where it stopped (i.e. data won't be truncated).
|
||||
*
|
||||
* @param \Box\Spout\Writer\Sheet $sheet The "external" sheet to set as current
|
||||
* @param \Box\Spout\Writer\XLSX\Sheet $sheet The "external" sheet to set as current
|
||||
* @return void
|
||||
* @throws \Box\Spout\Writer\Exception\SheetNotFoundException If the given sheet does not exist in the workbook
|
||||
*/
|
||||
@ -140,7 +140,7 @@ class Workbook
|
||||
/**
|
||||
* Returns the worksheet associated to the given external sheet.
|
||||
*
|
||||
* @param \Box\Spout\Writer\Sheet $sheet
|
||||
* @param \Box\Spout\Writer\XLSX\Sheet $sheet
|
||||
* @return Worksheet|null The worksheet associated to the given external sheet or null if not found.
|
||||
*/
|
||||
protected function getWorksheetFromExternalSheet($sheet)
|
@ -1,17 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer\Internal\XLSX;
|
||||
namespace Box\Spout\Writer\XLSX\Internal;
|
||||
|
||||
use Box\Spout\Common\Exception\InvalidArgumentException;
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Writer\Helper\XLSX\CellHelper;
|
||||
use Box\Spout\Writer\XLSX\Helper\CellHelper;
|
||||
|
||||
/**
|
||||
* Class Worksheet
|
||||
* Represents a worksheet within a XLSX file. The difference with the Sheet object is
|
||||
* that this class provides an interface to write data
|
||||
*
|
||||
* @package Box\Spout\Writer\Internal\XLSX
|
||||
* @package Box\Spout\Writer\XLSX\Internal
|
||||
*/
|
||||
class Worksheet
|
||||
{
|
||||
@ -20,13 +20,13 @@ class Worksheet
|
||||
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
||||
EOD;
|
||||
|
||||
/** @var \Box\Spout\Writer\Sheet The "external" sheet */
|
||||
/** @var \Box\Spout\Writer\XLSX\Sheet The "external" sheet */
|
||||
protected $externalSheet;
|
||||
|
||||
/** @var string Path to the XML file that will contain the sheet data */
|
||||
protected $worksheetFilePath;
|
||||
|
||||
/** @var \Box\Spout\Writer\Helper\XLSX\SharedStringsHelper Helper to write shared strings */
|
||||
/** @var \Box\Spout\Writer\XLSX\Helper\SharedStringsHelper Helper to write shared strings */
|
||||
protected $sharedStringsHelper;
|
||||
|
||||
/** @var bool Whether inline or shared strings should be used */
|
||||
@ -42,9 +42,9 @@ EOD;
|
||||
protected $lastWrittenRowIndex = 0;
|
||||
|
||||
/**
|
||||
* @param \Box\Spout\Writer\Sheet $externalSheet The associated "external" sheet
|
||||
* @param \Box\Spout\Writer\XLSX\Sheet $externalSheet The associated "external" sheet
|
||||
* @param string $worksheetFilesFolder Temporary folder where the files to create the XLSX will be stored
|
||||
* @param \Box\Spout\Writer\Helper\XLSX\SharedStringsHelper $sharedStringsHelper Helper for shared strings
|
||||
* @param \Box\Spout\Writer\XLSX\Helper\SharedStringsHelper $sharedStringsHelper Helper for shared strings
|
||||
* @param bool $shouldUseInlineStrings Whether inline or shared strings should be used
|
||||
* @throws \Box\Spout\Common\Exception\IOException If the sheet data file cannot be opened for writing
|
||||
*/
|
||||
@ -76,7 +76,7 @@ EOD;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Box\Spout\Writer\Sheet The "external" sheet
|
||||
* @return \Box\Spout\Writer\XLSX\Sheet The "external" sheet
|
||||
*/
|
||||
public function getExternalSheet()
|
||||
{
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer;
|
||||
namespace Box\Spout\Writer\XLSX;
|
||||
|
||||
/**
|
||||
* Class Sheet
|
||||
* Represents a worksheet within a XLSX file
|
||||
*
|
||||
* @package Box\Spout\Writer
|
||||
* @package Box\Spout\Writer\XLSX
|
||||
*/
|
||||
class Sheet
|
||||
{
|
||||
@ -45,7 +45,7 @@ class Sheet
|
||||
|
||||
/**
|
||||
* @param string $name Name of the sheet
|
||||
* @return \Box\Spout\Writer\Sheet
|
||||
* @return Sheet
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
@ -1,17 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer;
|
||||
namespace Box\Spout\Writer\XLSX;
|
||||
|
||||
use Box\Spout\Writer\AbstractWriter;
|
||||
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||
use Box\Spout\Writer\Internal\XLSX\Workbook;
|
||||
use Box\Spout\Writer\XLSX\Internal\Workbook;
|
||||
|
||||
/**
|
||||
* Class XLSX
|
||||
* Class Writer
|
||||
* This class provides base support to write data to XLSX files
|
||||
*
|
||||
* @package Box\Spout\Writer
|
||||
* @package Box\Spout\Writer\XLSX
|
||||
*/
|
||||
class XLSX extends AbstractWriter
|
||||
class Writer extends AbstractWriter
|
||||
{
|
||||
/** @var string Content-Type value for the header */
|
||||
protected static $headerContentType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
||||
@ -25,7 +26,7 @@ class XLSX extends AbstractWriter
|
||||
/** @var bool Whether new sheets should be automatically created when the max rows limit per sheet is reached */
|
||||
protected $shouldCreateNewSheetsAutomatically = true;
|
||||
|
||||
/** @var Internal\XLSX\Workbook The workbook for the XLSX file */
|
||||
/** @var Internal\Workbook The workbook for the XLSX file */
|
||||
protected $book;
|
||||
|
||||
/** @var int */
|
||||
@ -33,7 +34,7 @@ class XLSX extends AbstractWriter
|
||||
|
||||
/**
|
||||
* @param string $tempFolder Temporary folder where the files to create the XLSX will be stored
|
||||
* @return XLSX
|
||||
* @return Writer
|
||||
*/
|
||||
public function setTempFolder($tempFolder)
|
||||
{
|
||||
@ -45,7 +46,7 @@ class XLSX extends AbstractWriter
|
||||
* Use inline string to be more memory efficient. If set to false, it will use shared strings.
|
||||
*
|
||||
* @param bool $shouldUseInlineStrings Whether inline or shared strings should be used
|
||||
* @return XLSX
|
||||
* @return Writer
|
||||
*/
|
||||
public function setShouldUseInlineStrings($shouldUseInlineStrings)
|
||||
{
|
||||
@ -55,7 +56,7 @@ class XLSX extends AbstractWriter
|
||||
|
||||
/**
|
||||
* @param bool $shouldCreateNewSheetsAutomatically Whether new sheets should be automatically created when the max rows limit per sheet is reached
|
||||
* @return XLSX
|
||||
* @return Writer
|
||||
*/
|
||||
public function setShouldCreateNewSheetsAutomatically($shouldCreateNewSheetsAutomatically)
|
||||
{
|
||||
@ -91,7 +92,7 @@ class XLSX extends AbstractWriter
|
||||
$externalSheets = [];
|
||||
$worksheets = $this->book->getWorksheets();
|
||||
|
||||
/** @var Internal\XLSX\Worksheet $worksheet */
|
||||
/** @var Internal\Worksheet $worksheet */
|
||||
foreach ($worksheets as $worksheet) {
|
||||
$externalSheets[] = $worksheet->getExternalSheet();
|
||||
}
|
@ -1,16 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer;
|
||||
namespace Box\Spout\Writer\CSV;
|
||||
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\TestUsingResource;
|
||||
use Box\Spout\Writer\WriterFactory;
|
||||
|
||||
/**
|
||||
* Class CSVTest
|
||||
* Class WriterTest
|
||||
*
|
||||
* @package Box\Spout\Writer
|
||||
* @package Box\Spout\Writer\CSV
|
||||
*/
|
||||
class CSVTest extends \PHPUnit_Framework_TestCase
|
||||
class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
use TestUsingResource;
|
||||
|
||||
@ -69,7 +70,7 @@ class CSVTest extends \PHPUnit_Framework_TestCase
|
||||
];
|
||||
$writtenContent = $this->writeToCsvFileAndReturnWrittenContent($allRows, 'csv_with_utf8_bom.csv');
|
||||
|
||||
$this->assertContains(CSV::UTF8_BOM, $writtenContent, 'The CSV file should contain a UTF-8 BOM');
|
||||
$this->assertContains(Writer::UTF8_BOM, $writtenContent, 'The CSV file should contain a UTF-8 BOM');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,6 +162,6 @@ class CSVTest extends \PHPUnit_Framework_TestCase
|
||||
private function trimWrittenContent($writtenContent)
|
||||
{
|
||||
// remove line feeds and UTF-8 BOM
|
||||
return trim($writtenContent, PHP_EOL . CSV::UTF8_BOM);
|
||||
return trim($writtenContent, PHP_EOL . Writer::UTF8_BOM);
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer\Helper\XLSX;
|
||||
namespace Box\Spout\Writer\XLSX\Helper;
|
||||
|
||||
/**
|
||||
* Class CellHelperTest
|
||||
*
|
||||
* @package Box\Spout\Writer\Helper\XLSX
|
||||
* @package Box\Spout\Writer\XLSX\Helper
|
||||
*/
|
||||
class CellHelperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
@ -1,14 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer;
|
||||
namespace Box\Spout\Writer\XLSX;
|
||||
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\TestUsingResource;
|
||||
use Box\Spout\Writer\WriterFactory;
|
||||
|
||||
/**
|
||||
* Class SheetTest
|
||||
*
|
||||
* @package Box\Spout\Writer
|
||||
* @package Box\Spout\Writer\XLSX
|
||||
*/
|
||||
class SheetTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@ -69,7 +70,7 @@ class SheetTest extends \PHPUnit_Framework_TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX $writer */
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterFactory::create(Type::XLSX);
|
||||
$writer->openToFile($resourcePath);
|
||||
|
@ -1,16 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer;
|
||||
namespace Box\Spout\Writer\XLSX;
|
||||
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\TestUsingResource;
|
||||
use Box\Spout\Writer\WriterFactory;
|
||||
|
||||
/**
|
||||
* Class XLSXTest
|
||||
*
|
||||
* @package Box\Spout\Writer
|
||||
*/
|
||||
class XLSXTest extends \PHPUnit_Framework_TestCase
|
||||
class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
use TestUsingResource;
|
||||
|
||||
@ -230,7 +231,7 @@ class XLSXTest extends \PHPUnit_Framework_TestCase
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX $writer */
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterFactory::create(Type::XLSX);
|
||||
$writer->setShouldUseInlineStrings(true);
|
||||
|
||||
@ -278,7 +279,7 @@ class XLSXTest extends \PHPUnit_Framework_TestCase
|
||||
];
|
||||
|
||||
// set the maxRowsPerSheet limit to 2
|
||||
\ReflectionHelper::setStaticValue('\Box\Spout\Writer\Internal\XLSX\Workbook', 'maxRowsPerWorksheet', 2);
|
||||
\ReflectionHelper::setStaticValue('\Box\Spout\Writer\XLSX\Internal\Workbook', 'maxRowsPerWorksheet', 2);
|
||||
|
||||
$writer = $this->writeToXLSXFile($dataRows, $fileName, true, $shouldCreateSheetsAutomatically = true);
|
||||
$this->assertEquals(2, count($writer->getSheets()), '2 sheets should have been created.');
|
||||
@ -302,7 +303,7 @@ class XLSXTest extends \PHPUnit_Framework_TestCase
|
||||
];
|
||||
|
||||
// set the maxRowsPerSheet limit to 2
|
||||
\ReflectionHelper::setStaticValue('\Box\Spout\Writer\Internal\XLSX\Workbook', 'maxRowsPerWorksheet', 2);
|
||||
\ReflectionHelper::setStaticValue('\Box\Spout\Writer\XLSX\Internal\Workbook', 'maxRowsPerWorksheet', 2);
|
||||
|
||||
$writer = $this->writeToXLSXFile($dataRows, $fileName, true, $shouldCreateSheetsAutomatically = false);
|
||||
$this->assertEquals(1, count($writer->getSheets()), 'Only 1 sheet should have been created.');
|
||||
@ -348,14 +349,14 @@ class XLSXTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $fileName
|
||||
* @param bool $shouldUseInlineStrings
|
||||
* @param bool $shouldCreateSheetsAutomatically
|
||||
* @return XLSX
|
||||
* @return Writer
|
||||
*/
|
||||
private function writeToXLSXFile($allRows, $fileName, $shouldUseInlineStrings = true, $shouldCreateSheetsAutomatically = true)
|
||||
{
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX $writer */
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterFactory::create(Type::XLSX);
|
||||
$writer->setShouldUseInlineStrings($shouldUseInlineStrings);
|
||||
$writer->setShouldCreateNewSheetsAutomatically($shouldCreateSheetsAutomatically);
|
||||
@ -373,14 +374,14 @@ class XLSXTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $fileName
|
||||
* @param bool $shouldUseInlineStrings
|
||||
* @param bool $shouldCreateSheetsAutomatically
|
||||
* @return XLSX
|
||||
* @return Writer
|
||||
*/
|
||||
private function writeToMultipleSheetsInXLSXFile($allRows, $numSheets, $fileName, $shouldUseInlineStrings = true, $shouldCreateSheetsAutomatically = true)
|
||||
{
|
||||
$this->createGeneratedFolderIfNeeded($fileName);
|
||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX $writer */
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterFactory::create(Type::XLSX);
|
||||
$writer->setShouldUseInlineStrings($shouldUseInlineStrings);
|
||||
$writer->setShouldCreateNewSheetsAutomatically($shouldCreateSheetsAutomatically);
|
Loading…
x
Reference in New Issue
Block a user