Merge 9bd56fce5232f95acb3cae1e78d9bbff2afec750 into 40b4a57e6bfb29a7134542a824773495ed165b2f

This commit is contained in:
Aron Budinszky 2017-06-26 15:23:23 +00:00 committed by GitHub
commit e912d68be1
4 changed files with 17 additions and 5 deletions

View File

@ -37,7 +37,7 @@ abstract class AbstractWriter implements WriterInterface
protected $defaultRowStyle; protected $defaultRowStyle;
/** @var string Content-Type value for the header - to be defined by child class */ /** @var string Content-Type value for the header - to be defined by child class */
protected static $headerContentType; protected $headerContentType;
/** /**
* Opens the streamer and makes it ready to accept data. * Opens the streamer and makes it ready to accept data.
@ -143,7 +143,7 @@ abstract class AbstractWriter implements WriterInterface
$this->globalFunctionsHelper->ob_end_clean(); $this->globalFunctionsHelper->ob_end_clean();
// Set headers // Set headers
$this->globalFunctionsHelper->header('Content-Type: ' . static::$headerContentType); $this->globalFunctionsHelper->header('Content-Type: ' . $this->headerContentType);
$this->globalFunctionsHelper->header('Content-Disposition: attachment; filename="' . $this->outputFilePath . '"'); $this->globalFunctionsHelper->header('Content-Disposition: attachment; filename="' . $this->outputFilePath . '"');
/* /*

View File

@ -18,7 +18,7 @@ class Writer extends AbstractWriter
const FLUSH_THRESHOLD = 500; const FLUSH_THRESHOLD = 500;
/** @var string Content-Type value for the header */ /** @var string Content-Type value for the header */
protected static $headerContentType = 'text/csv; charset=UTF-8'; protected $headerContentType = 'text/csv; charset=UTF-8';
/** @var string Defines the character used to delimit fields (one character only) */ /** @var string Defines the character used to delimit fields (one character only) */
protected $fieldDelimiter = ','; protected $fieldDelimiter = ',';
@ -58,6 +58,18 @@ class Writer extends AbstractWriter
return $this; return $this;
} }
/**
* Set the header content type.
*
* @param string $headerContentType Content-Type value for the header if different than default UTF-8.
* @return Writer
*/
public function setHeaderContentType($headerContentType)
{
$this->headerContentType = $headerContentType;
return $this;
}
/** /**
* Set if a BOM has to be added to the file * Set if a BOM has to be added to the file
* *

View File

@ -15,7 +15,7 @@ use Box\Spout\Writer\ODS\Internal\Workbook;
class Writer extends AbstractMultiSheetsWriter class Writer extends AbstractMultiSheetsWriter
{ {
/** @var string Content-Type value for the header */ /** @var string Content-Type value for the header */
protected static $headerContentType = 'application/vnd.oasis.opendocument.spreadsheet'; protected $headerContentType = 'application/vnd.oasis.opendocument.spreadsheet';
/** @var string Temporary folder where the files to create the ODS will be stored */ /** @var string Temporary folder where the files to create the ODS will be stored */
protected $tempFolder; protected $tempFolder;

View File

@ -19,7 +19,7 @@ class Writer extends AbstractMultiSheetsWriter
const DEFAULT_FONT_NAME = 'Calibri'; const DEFAULT_FONT_NAME = 'Calibri';
/** @var string Content-Type value for the header */ /** @var string Content-Type value for the header */
protected static $headerContentType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; protected $headerContentType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
/** @var string Temporary folder where the files to create the XLSX will be stored */ /** @var string Temporary folder where the files to create the XLSX will be stored */
protected $tempFolder; protected $tempFolder;