Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Class: Csv  - X-Ref

__construct()   X-Ref
Create a new CSV Reader instance.


setConstructorCallback(?callable $callback)   X-Ref
Set a callback to change the defaults.

The callback must accept the Csv Reader object as the first parameter,
and it should return void.

getConstructorCallback()   X-Ref
No description

setInputEncoding(string $encoding)   X-Ref
No description

getInputEncoding()   X-Ref
No description

setFallbackEncoding(string $fallbackEncoding)   X-Ref
No description

getFallbackEncoding()   X-Ref
No description

skipBOM()   X-Ref
Move filepointer past any BOM marker.


checkSeparator()   X-Ref
Identify any separator that is explicitly set in the file.


inferSeparator()   X-Ref
Infer the separator if it isn't explicitly set in the file or specified by the user.


listWorksheetInfo(string $filename)   X-Ref
Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).


loadSpreadsheetFromFile(string $filename)   X-Ref
Loads Spreadsheet from file.


loadSpreadsheetFromString(string $contents)   X-Ref
Loads Spreadsheet from string.


openFileOrMemory(string $filename)   X-Ref
No description

setTestAutoDetect(bool $value)   X-Ref
No description

setAutoDetect(?string $value)   X-Ref
No description

castFormattedNumberToNumeric(bool $castFormattedNumberToNumeric,bool $preserveNumericFormatting = false)   X-Ref
No description

openDataUri(string $filename)   X-Ref
Open data uri for reading.


loadIntoExisting(string $filename, Spreadsheet $spreadsheet)   X-Ref
Loads PhpSpreadsheet from file into PhpSpreadsheet instance.


loadStringOrFile(string $filename, Spreadsheet $spreadsheet, bool $dataUri)   X-Ref
Loads PhpSpreadsheet from file into PhpSpreadsheet instance.


convertBoolean(&$rowDatum, bool $preserveBooleanString)   X-Ref
Convert string true/false to boolean, and null to null-string.

param: mixed $rowDatum

convertFormattedNumber(&$rowDatum)   X-Ref
Convert numeric strings to int or float values.

param: mixed $rowDatum

getDelimiter()   X-Ref
No description

setDelimiter(?string $delimiter)   X-Ref
No description

getEnclosure()   X-Ref
No description

setEnclosure(string $enclosure)   X-Ref
No description

getSheetIndex()   X-Ref
No description

setSheetIndex(int $indexValue)   X-Ref
No description

setContiguous(bool $contiguous)   X-Ref
No description

getContiguous()   X-Ref
No description

setEscapeCharacter(string $escapeCharacter)   X-Ref
No description

getEscapeCharacter()   X-Ref
No description

canRead(string $filename)   X-Ref
Can the current IReader read the file?


guessEncodingTestNoBom(string &$encoding, string &$contents, string $compare, string $setEncoding)   X-Ref
No description

guessEncodingNoBom(string $filename)   X-Ref
No description

guessEncodingTestBom(string &$encoding, string $first4, string $compare, string $setEncoding)   X-Ref
No description

guessEncodingBom(string $filename)   X-Ref
No description

guessEncoding(string $filename, string $dflt = self::DEFAULT_FALLBACK_ENCODING)   X-Ref
No description

setPreserveNullString(bool $value)   X-Ref
No description

getPreserveNullString()   X-Ref
No description