PHP Класс Box\Spout\Writer\AbstractWriter

Наследование: implements Box\Spout\Writer\WriterInterface
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$defaultRowStyle Default row style. Each writer can have its own default style
$filePointer Pointer to the file/stream we will write to
$globalFunctionsHelper Helper to work with global functions
$headerContentType Content-Type value for the header - to be defined by child class
$isWriterOpened Indicates whether the writer has been opened or not
$outputFilePath Path to the output file
$rowStyle Style to be applied to the next written row(s)

Открытые методы

Метод Описание
__construct ( )
addRow ( array $dataRow ) : AbstractWriter Write given data to the output. New data will be appended to end of stream.
addRowWithStyle ( array $dataRow, Style $style ) : AbstractWriter Write given data to the output and apply the given style.
addRows ( array $dataRows ) : AbstractWriter Write given data to the output. New data will be appended to end of stream.
addRowsWithStyle ( array $dataRows, Style $style ) : AbstractWriter Write given data to the output and apply the given style.
close ( ) : void Closes the writer. This will close the streamer as well, preventing new data to be written to the file.
openToBrowser ( string $outputFileName ) : AbstractWriter Inits the writer and opens it to accept data.
openToFile ( string $outputFilePath ) : AbstractWriter Inits the writer and opens it to accept data.
setDefaultRowStyle ( Style $defaultStyle ) : AbstractWriter Sets the default styles for all rows added with "addRow".
setGlobalFunctionsHelper ( Box\Spout\Common\Helper\GlobalFunctionsHelper $globalFunctionsHelper ) : AbstractWriter

Защищенные методы

Метод Описание
addRowToWriter ( array $dataRow, Style $style ) : void Adds data to the currently openned writer.
closeWriter ( ) : void Closes the streamer, preventing any additional writing.
getDefaultRowStyle ( ) : Style Returns the default style to be applied to rows.
openWriter ( ) : void Opens the streamer and makes it ready to accept data.
throwIfFilePointerIsNotAvailable ( ) : void Checks if the pointer to the file/stream to write to is available.
throwIfWriterAlreadyOpened ( string $message ) : void Checks if the writer has already been opened, since some actions must be done before it gets opened.

Приватные методы

Метод Описание
closeAndAttemptToCleanupAllFiles ( ) : void Closes the writer and attempts to cleanup all files that were created during the writing process (temp files & final file).
resetRowStyleToDefault ( ) : void Resets the style to be applied to the next written rows.
setRowStyle ( Style $style ) : void Sets the style to be applied to the next written rows until it is changed or reset.

Описание методов

__construct() публичный Метод

public __construct ( )

addRow() публичный Метод

Write given data to the output. New data will be appended to end of stream.
public addRow ( array $dataRow ) : AbstractWriter
$dataRow array Array containing data to be streamed. If empty, no data is added (i.e. not even as a blank row) Example: $dataRow = ['data1', 1234, null, '', 'data5', false];
Результат AbstractWriter

addRowToWriter() абстрактный защищенный Метод

Adds data to the currently openned writer.
abstract protected addRowToWriter ( array $dataRow, Style $style ) : void
$dataRow array Array containing data to be streamed. Example $dataRow = ['data1', 1234, null, '', 'data5'];
$style Box\Spout\Writer\Style\Style Style to be applied to the written row
Результат void

addRowWithStyle() публичный Метод

Write given data to the output and apply the given style.
См. также: addRow
public addRowWithStyle ( array $dataRow, Style $style ) : AbstractWriter
$dataRow array Array of array containing data to be streamed.
$style Box\Spout\Writer\Style\Style Style to be applied to the row.
Результат AbstractWriter

addRows() публичный Метод

Write given data to the output. New data will be appended to end of stream.
public addRows ( array $dataRows ) : AbstractWriter
$dataRows array Array of array containing data to be streamed. If a row is empty, it won't be added (i.e. not even as a blank row) Example: $dataRows = [ ['data11', 12, , '', 'data13'], ['data21', 'data22', null, false], ];
Результат AbstractWriter

addRowsWithStyle() публичный Метод

Write given data to the output and apply the given style.
См. также: addRows
public addRowsWithStyle ( array $dataRows, Style $style ) : AbstractWriter
$dataRows array Array of array containing data to be streamed.
$style Box\Spout\Writer\Style\Style Style to be applied to the rows.
Результат AbstractWriter

close() публичный Метод

Closes the writer. This will close the streamer as well, preventing new data to be written to the file.
public close ( ) : void
Результат void

closeWriter() абстрактный защищенный Метод

Closes the streamer, preventing any additional writing.
abstract protected closeWriter ( ) : void
Результат void

getDefaultRowStyle() защищенный Метод

Can be overriden by children to have a custom style.
protected getDefaultRowStyle ( ) : Style
Результат Box\Spout\Writer\Style\Style

openToBrowser() публичный Метод

By using this method, the data will be outputted directly to the browser.
public openToBrowser ( string $outputFileName ) : AbstractWriter
$outputFileName string Name of the output file that will contain the data. If a path is passed in, only the file name will be kept
Результат AbstractWriter

openToFile() публичный Метод

By using this method, the data will be written to a file.
public openToFile ( string $outputFilePath ) : AbstractWriter
$outputFilePath string Path of the output file that will contain the data
Результат AbstractWriter

openWriter() абстрактный защищенный Метод

Opens the streamer and makes it ready to accept data.
abstract protected openWriter ( ) : void
Результат void

setDefaultRowStyle() публичный Метод

Overriding the default style instead of using "addRowWithStyle" improves performance by 20%.
См. также: https://github.com/box/spout/issues/272
public setDefaultRowStyle ( Style $defaultStyle ) : AbstractWriter
$defaultStyle Box\Spout\Writer\Style\Style
Результат AbstractWriter

setGlobalFunctionsHelper() публичный Метод

public setGlobalFunctionsHelper ( Box\Spout\Common\Helper\GlobalFunctionsHelper $globalFunctionsHelper ) : AbstractWriter
$globalFunctionsHelper Box\Spout\Common\Helper\GlobalFunctionsHelper
Результат AbstractWriter

throwIfFilePointerIsNotAvailable() защищенный Метод

Will throw an exception if not available.
protected throwIfFilePointerIsNotAvailable ( ) : void
Результат void

throwIfWriterAlreadyOpened() защищенный Метод

Throws an exception if already opened.
protected throwIfWriterAlreadyOpened ( string $message ) : void
$message string Error message
Результат void

Описание свойств

$defaultRowStyle защищенное свойство

Default row style. Each writer can have its own default style
protected $defaultRowStyle

$filePointer защищенное свойство

Pointer to the file/stream we will write to
protected $filePointer

$globalFunctionsHelper защищенное свойство

Helper to work with global functions
protected $globalFunctionsHelper

$headerContentType защищенное статическое свойство

Content-Type value for the header - to be defined by child class
protected static $headerContentType

$isWriterOpened защищенное свойство

Indicates whether the writer has been opened or not
protected $isWriterOpened

$outputFilePath защищенное свойство

Path to the output file
protected $outputFilePath

$rowStyle защищенное свойство

Style to be applied to the next written row(s)
protected $rowStyle