Moodle PHP Documentation 4.1
Moodle 4.1.19+ (Build: 20250711) (5f47dc23ffc)
Box\Spout\Writer\ODS\Writer Class Reference
Inheritance diagram for Box\Spout\Writer\ODS\Writer:
Box\Spout\Writer\WriterMultiSheetsAbstract Box\Spout\Writer\WriterAbstract Box\Spout\Writer\WriterInterface

Public Member Functions

 addNewSheetAndMakeItCurrent ()
 Creates a new sheet and make it the current sheet.
 
 addRow (Row $row)
 {Appends a row to the end of the stream.
Parameters
Row$rowThe row to be appended to the stream
Exceptions
Box\Spout\Writer\Exception\WriterNotOpenedExceptionIf the writer has not been opened yet
Box\Spout\Common\Exception\IOExceptionIf unable to write data
Return values
WriterInterface
}
 
 addRows (array $rows)
 {Appends the rows to the end of the stream.
Parameters
Row[]$rowsThe rows to be appended to the stream
Exceptions
Box\Spout\Common\Exception\InvalidArgumentExceptionIf the input param is not valid
Box\Spout\Writer\Exception\WriterNotOpenedExceptionIf the writer has not been opened yet
Box\Spout\Common\Exception\IOExceptionIf unable to write data
Return values
WriterInterface
}
 
 close ()
 {Closes the writer.This will close the streamer as well, preventing new data to be written to the file.
Return values
void
}
 
 getCurrentSheet ()
 Returns the current sheet.
 
 getSheets ()
 Returns all the workbook's sheets.
 
 openToBrowser ($outputFileName)
 @codeCoverageIgnore {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
Box\Spout\Common\Exception\IOExceptionIf the writer cannot be opened
Return values
WriterInterface
}
 
 openToFile ($outputFilePath)
 {Initializes the writer and opens it to accept data.By using this method, the data will be written to a file.
Parameters
string$outputFilePathPath of the output file that will contain the data
Exceptions
Box\Spout\Common\Exception\IOExceptionIf the writer cannot be opened or if the given path is not writable
Return values
WriterInterface
}
 
 setCurrentSheet ($sheet)
 Sets the given sheet as the current one.
 
 setDefaultRowStyle (Style $defaultStyle)
 {Sets the default styles for all rows added with "addRow".Overriding the default style instead of using "addRowWithStyle" improves performance by 20%.

See also
https://github.com/box/spout/issues/272
Parameters
Style$defaultStyle
Return values
WriterInterface
}
 
 setShouldCreateNewSheetsAutomatically ($shouldCreateNewSheetsAutomatically)
 Sets whether new sheets should be automatically created when the max rows limit per sheet is reached.
 
 setTempFolder ($tempFolder)
 Sets a custom temporary folder for creating intermediate files/folders.
 

Protected Member Functions

 addRowToWriter (Row $row)
 {Adds a row to the currently opened writer.
Parameters
Row$rowThe row containing cells and styles
Exceptions
WriterNotOpenedExceptionIf the workbook is not created yet
IOExceptionIf unable to write data
Return values
void
}
 
 closeWriter ()
 {Closes the streamer, preventing any additional writing.
Return values
void
}
 
 openWriter ()
 {Opens the streamer and makes it ready to accept data.
Exceptions
IOExceptionIf the writer cannot be opened
Return values
void
}
 
 throwIfFilePointerIsNotAvailable ()
 Checks if the pointer to the file/stream to write to is available.
 
 throwIfWorkbookIsNotAvailable ()
 Checks if the workbook has been created.
 
 throwIfWriterAlreadyOpened ($message)
 Checks if the writer has already been opened, since some actions must be done before it gets opened.
 

Protected Attributes

resource $filePointer
 Pointer to the file/stream we will write to.
 
GlobalFunctionsHelper $globalFunctionsHelper
 Helper to work with global functions.
 
HelperFactory $helperFactory
 
bool $isWriterOpened = false
 Indicates whether the writer has been opened or not.
 
OptionsManagerInterface $optionsManager
 Writer options manager.
 
string $outputFilePath
 Path to the output file.
 

Static Protected Attributes

static string $headerContentType = 'application/vnd.oasis.opendocument.spreadsheet'
 Content-Type value for the header.
 

Member Function Documentation

◆ addNewSheetAndMakeItCurrent()

Box\Spout\Writer\WriterMultiSheetsAbstract::addNewSheetAndMakeItCurrent ( )
inherited

Creates a new sheet and make it the current sheet.

The data will now be written to this sheet.

Exceptions
WriterNotOpenedExceptionIf the writer has not been opened yet
Return values
SheetThe created sheet

◆ addRow()

Box\Spout\Writer\WriterAbstract::addRow ( Row $row)
inherited

{Appends a row to the end of the stream.

Parameters
Row$rowThe row to be appended to the stream
Exceptions
Box\Spout\Writer\Exception\WriterNotOpenedExceptionIf the writer has not been opened yet
Box\Spout\Common\Exception\IOExceptionIf unable to write data
Return values
WriterInterface
}

Implements Box\Spout\Writer\WriterInterface.

◆ addRows()

Box\Spout\Writer\WriterAbstract::addRows ( array $rows)
inherited

{Appends the rows to the end of the stream.

Parameters
Row[]$rowsThe rows to be appended to the stream
Exceptions
Box\Spout\Common\Exception\InvalidArgumentExceptionIf the input param is not valid
Box\Spout\Writer\Exception\WriterNotOpenedExceptionIf the writer has not been opened yet
Box\Spout\Common\Exception\IOExceptionIf unable to write data
Return values
WriterInterface
}

Implements Box\Spout\Writer\WriterInterface.

◆ addRowToWriter()

Box\Spout\Writer\WriterMultiSheetsAbstract::addRowToWriter ( Row $row)
protectedinherited

{Adds a row to the currently opened writer.

Parameters
Row$rowThe row containing cells and styles
Exceptions
WriterNotOpenedExceptionIf the workbook is not created yet
IOExceptionIf unable to write data
Return values
void
}

Reimplemented from Box\Spout\Writer\WriterAbstract.

◆ close()

Box\Spout\Writer\WriterAbstract::close ( )
inherited

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

Return values
void
}

Implements Box\Spout\Writer\WriterInterface.

◆ closeWriter()

Box\Spout\Writer\WriterMultiSheetsAbstract::closeWriter ( )
protectedinherited

{Closes the streamer, preventing any additional writing.

Return values
void
}

Reimplemented from Box\Spout\Writer\WriterAbstract.

◆ getCurrentSheet()

Box\Spout\Writer\WriterMultiSheetsAbstract::getCurrentSheet ( )
inherited

Returns the current sheet.

Exceptions
WriterNotOpenedExceptionIf the writer has not been opened yet
Return values
SheetThe current sheet

◆ getSheets()

Box\Spout\Writer\WriterMultiSheetsAbstract::getSheets ( )
inherited

Returns all the workbook's sheets.

Exceptions
WriterNotOpenedExceptionIf the writer has not been opened yet
Return values
Sheet[]All the workbook's sheets

◆ openToBrowser()

Box\Spout\Writer\WriterAbstract::openToBrowser ( $outputFileName)
inherited

@codeCoverageIgnore {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
Box\Spout\Common\Exception\IOExceptionIf the writer cannot be opened
Return values
WriterInterface
}

Implements Box\Spout\Writer\WriterInterface.

◆ openToFile()

Box\Spout\Writer\WriterAbstract::openToFile ( $outputFilePath)
inherited

{Initializes the writer and opens it to accept data.By using this method, the data will be written to a file.

Parameters
string$outputFilePathPath of the output file that will contain the data
Exceptions
Box\Spout\Common\Exception\IOExceptionIf the writer cannot be opened or if the given path is not writable
Return values
WriterInterface
}

Implements Box\Spout\Writer\WriterInterface.

◆ openWriter()

Box\Spout\Writer\WriterMultiSheetsAbstract::openWriter ( )
protectedinherited

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

Exceptions
IOExceptionIf the writer cannot be opened
Return values
void
}

Reimplemented from Box\Spout\Writer\WriterAbstract.

◆ setCurrentSheet()

Box\Spout\Writer\WriterMultiSheetsAbstract::setCurrentSheet ( $sheet)
inherited

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).

Parameters
Sheet$sheetThe sheet to set as current
Exceptions
WriterNotOpenedExceptionIf the writer has not been opened yet
SheetNotFoundExceptionIf the given sheet does not exist in the workbook
Return values
void

◆ setDefaultRowStyle()

Box\Spout\Writer\WriterAbstract::setDefaultRowStyle ( Style $defaultStyle)
inherited

{Sets the default styles for all rows added with "addRow".Overriding the default style instead of using "addRowWithStyle" improves performance by 20%.

See also
https://github.com/box/spout/issues/272
Parameters
Style$defaultStyle
Return values
WriterInterface
}

Implements Box\Spout\Writer\WriterInterface.

◆ setShouldCreateNewSheetsAutomatically()

Box\Spout\Writer\WriterMultiSheetsAbstract::setShouldCreateNewSheetsAutomatically ( $shouldCreateNewSheetsAutomatically)
inherited

Sets whether new sheets should be automatically created when the max rows limit per sheet is reached.

This must be set before opening the writer.

Parameters
bool$shouldCreateNewSheetsAutomaticallyWhether new sheets should be automatically created when the max rows limit per sheet is reached
Exceptions
WriterAlreadyOpenedExceptionIf the writer was already opened
Return values
WriterMultiSheetsAbstract

◆ setTempFolder()

Box\Spout\Writer\ODS\Writer::setTempFolder ( $tempFolder)

Sets a custom temporary folder for creating intermediate files/folders.

This must be set before opening the writer.

Parameters
string$tempFolderTemporary folder where the files to create the ODS will be stored
Exceptions
Box\Spout\Writer\Exception\WriterAlreadyOpenedExceptionIf the writer was already opened
Return values
Writer

◆ throwIfFilePointerIsNotAvailable()

Box\Spout\Writer\WriterAbstract::throwIfFilePointerIsNotAvailable ( )
protectedinherited

Checks if the pointer to the file/stream to write to is available.

Will throw an exception if not available.

Exceptions
IOExceptionIf the pointer is not available
Return values
void

◆ throwIfWorkbookIsNotAvailable()

Box\Spout\Writer\WriterMultiSheetsAbstract::throwIfWorkbookIsNotAvailable ( )
protectedinherited

Checks if the workbook has been created.

Throws an exception if not created yet.

Exceptions
WriterNotOpenedExceptionIf the workbook is not created yet
Return values
void

◆ throwIfWriterAlreadyOpened()

Box\Spout\Writer\WriterAbstract::throwIfWriterAlreadyOpened ( $message)
protectedinherited

Checks if the writer has already been opened, since some actions must be done before it gets opened.

Throws an exception if already opened.

Parameters
string$messageError message
Exceptions
WriterAlreadyOpenedExceptionIf the writer was already opened and must not be.
Return values
void

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