Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
OpenSpout\Writer\CSV\Writer Class Reference
Inheritance diagram for OpenSpout\Writer\CSV\Writer:
OpenSpout\Writer\AbstractWriter OpenSpout\Writer\WriterInterface

Public Member Functions

 __construct (?Options $options=null)
 
 addRow (Row $row)
 Appends a row to the end of the stream.
 
 addRows (array $rows)
 Appends the rows to the end of the stream.
 
 close ()
 Closes the writer.
 
 getOptions ()
 
 getWrittenRowCount ()
 
 openToBrowser ($outputFileName)
 @codeCoverageIgnore
 
 openToBrowser (string $outputFileName)
 Initializes the writer and opens it to accept data.
 
 openToFile ($outputFilePath)
 
 openToFile (string $outputFilePath)
 
 setCreator (string $creator)
 Set document creator.
 

Protected Member Functions

 addRowToWriter (Row $row)
 Adds a row to the currently opened writer.
 
 closeWriter ()
 Closes the CSV streamer, preventing any additional writing.
 
 openWriter ()
 Opens the CSV streamer and makes it ready to accept data.
 

Protected Attributes

string string $creator = 'OpenSpout'
 document creator
 
resource file home runner work phpdoc phpdoc moodle lib openspout src Writer AbstractWriter php $filePointer
 Pointer to the file/stream we will write to.
 

Static Protected Attributes

string file home runner work phpdoc phpdoc moodle lib openspout src Writer CSV Writer php static string $headerContentType = 'text/csv; charset=UTF-8'
 Content-Type value for the header.
 

Member Function Documentation

◆ addRow()

OpenSpout\Writer\AbstractWriter::addRow ( Row $row)
finalinherited

Appends a row to the end of the stream.

Parameters
Row$rowThe row to be appended to the stream
Exceptions
Exception\WriterNotOpenedExceptionIf the writer has not been opened yet
IOExceptionIf unable to write data

Implements OpenSpout\Writer\WriterInterface.

◆ addRows()

OpenSpout\Writer\AbstractWriter::addRows ( array $rows)
finalinherited

Appends the rows to the end of the stream.

Parameters
Row[]$rowsThe rows to be appended to the stream
Exceptions
InvalidArgumentExceptionIf the input param is not valid
Exception\WriterNotOpenedExceptionIf the writer has not been opened yet
IOExceptionIf unable to write data

Implements OpenSpout\Writer\WriterInterface.

◆ addRowToWriter()

OpenSpout\Writer\CSV\Writer::addRowToWriter ( Row $row)
protected

Adds a row to the currently opened writer.

Parameters
Row$rowThe row containing cells and styles
Exceptions
IOExceptionIf unable to write data

Reimplemented from OpenSpout\Writer\AbstractWriter.

◆ close()

OpenSpout\Writer\AbstractWriter::close ( )
finalinherited

Closes the writer.

This will close the streamer as well, preventing new data to be written to the file.

Implements OpenSpout\Writer\WriterInterface.

◆ closeWriter()

OpenSpout\Writer\CSV\Writer::closeWriter ( )
protected

Closes the CSV streamer, preventing any additional writing.

If set, sets the headers and redirects output to the browser.

Reimplemented from OpenSpout\Writer\AbstractWriter.

◆ getWrittenRowCount()

OpenSpout\Writer\AbstractWriter::getWrittenRowCount ( )
finalinherited
Return values
0|positive-int

Implements OpenSpout\Writer\WriterInterface.

◆ openToBrowser() [1/2]

OpenSpout\Writer\AbstractWriter::openToBrowser ( $outputFileName)
finalinherited

@codeCoverageIgnore

Parameters
mixed$outputFileName

◆ openToBrowser() [2/2]

OpenSpout\Writer\WriterInterface::openToBrowser ( string $outputFileName)
inherited

Initializes the writer and opens it to accept data.

By using this method, the data will be outputted directly to the browser.

Parameters
string$outputFileNameName of the output file that will contain the data. If a path is passed in, only the file name will be kept
Exceptions
IOExceptionIf the writer cannot be opened

◆ openWriter()

OpenSpout\Writer\CSV\Writer::openWriter ( )
protected

Opens the CSV streamer and makes it ready to accept data.

Reimplemented from OpenSpout\Writer\AbstractWriter.

◆ setCreator()

OpenSpout\Writer\AbstractWriter::setCreator ( string $creator)
finalinherited

Set document creator.

Parameters
string$creatordocument creator

Implements OpenSpout\Writer\WriterInterface.


The documentation for this class was generated from the following file: